Searched for a solution, but couldn't find any. My program needs to save the game state at program end. Problem is that if the window is closed by someone clicking the x in the corner, the program ends immediately, no chance to save the state.
Example
// Project: ttt
// Created: 2019-08-19
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "ttt" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
do
if GetRawKeyPressed(27) then exit
Print( ScreenFPS() )
Sync()
loop
Message("Saving state")
Press escape and the message box appears, press the x to close the window, message box does not appear.