If, like me, you are annoyed by having to mouse-click the X to end a Godot game, this is a good point to add an “exit” action bound to the Escape key. Then add in the following to your input-handling code:
if Input.is_action_just_pressed("exit"):
get_tree().quit()
Cheers.