How to detect application exit


How to detect application (SimpleApplication) stop with listener or method override to be able to gracefully shutdown other system components when user closes window or presses ESC?

Best regards,

Hm the must low level way is just a normal java shutdown hook. This should be called on all non externally forced exists. (eg Taskmanager on windows)

Then you could use an appstate that is just there to notice the shutdown, if i remmber right they have a method that gets called on shutdown.

1 Like

AppState.cleanup() is called when the app is shut down and it’s the friendly JME way to do such a thing… especially as you mention “other system components” which probably should have been managed by app states in the first place.

1 Like

Thank you! :slight_smile: