I am using a library which needs to be cleaned up at exit time (i.e. closing a socket so that it does not hang until some timeout) in an OpenFL 2.2.1 application.
However, I could not find any event which is called when I close the window with Alt+F4 or the closing button of the window.
How can I detect that the application is terminating, in order to clean my resources?
To answer your question about
openfl-next, there is thelime.app.Application.onExitevent, which it inherits fromlime.app.Module. AnApplicationreference is stored inopenfl.display.Stage.applicationinstance field.So, a multi-version variant of the function would be as following:
And then you would just