application-quit-handler in System Menus

When the current eventspace is the initial eventspace, this procedure retrieves or installs a thunk that is called when the user requests that the application quit (e.g., through the Quit menu item in Mac OS X, or when shutting down the machine in Windows). The thunk is always called in the initial eventspace's handler thread (as a callback). If the result of the thunk is #f, then the operating system is explicitly notified that the application does not intend to quit (under Windows).

The default handler queues a call to the can-exit? method of the most recently active frame in the initial eventspace (and then calls the frame's on-exit method if the result is true). The result is is #t if the eventspace is left with no open frames after on-exit returns, #f otherwise.