Up to date

This page is up to date for Godot 4.0. If you still find outdated information, please open an issue.

Handling quit requests


Most platforms have the option to request the application to quit. On desktops, this is usually done with the "x" icon on the window title bar. On Android, the back button is used to quit when on the main screen (and to go back otherwise).

Handling the notification

On desktop and web platforms, Node receives a special NOTIFICATION_WM_CLOSE_REQUEST notification when quitting is requested from the window manager.

On Android, NOTIFICATION_WM_GO_BACK_REQUEST is sent instead. Pressing the Back button will exit the application if Application > Config > Quit On Go Back is checked in the Project Settings (which is the default).


NOTIFICATION_WM_GO_BACK_REQUEST isn't supported on iOS, as iOS devices don't have a physical Back button.

Handling the notification is done as follows (on any node):

func _notification(what):
        get_tree().quit() # default behavior

When developing mobile apps, quitting is not desired unless the user is on the main screen, so the behavior can be changed.

It is important to note that by default, Godot apps have the built-in behavior to quit when quit is requested from the window manager. This can be changed, so that the user can take care of the complete quitting procedure: