I put this type of cleanup in the hiding events on...
# tornadofx
c
I put this type of cleanup in the hiding events on the main Stage (onUnDock in TornadoFX). You'll want some UI left to report what's going on with the shutdown, giving the users the option to do a hard shutdown. The other handlers I can think of like the java shutdown handlers or stop() in the Application class might give your app a long pause between the last visible UI component and the icon at the bottom of the screen.