Also late to the party but this might help someone else...
Create a project with a Node2D, and two child nodes: an AcceptDialog and a Button. Link the button's signal to a function in Node 2D like this, to show the dialog when the button is pressed
extends Node2D
var quit = false
func _ready():
pass
func _process(delta):
if quit:
get_tree().quit()
func _on_Button_button_down():
$AcceptDialog.show_modal(true)
Then, add a script to AcceptDialog:
extends AcceptDialog
func _ready():
pass
#func _process(delta):
# # Called every frame. Delta is time since last frame.
# # Update game logic here.
# pass
func _on_AcceptDialog_confirmed():
get_node("..").quit = true
When the used confirms via the dialog's OK button the 'quit' variable in Node2D is set to true and when control returns to Node2D the app is closed in the next call to _process.