title: Libgdx on desktop, how to handle disposing when window is closed
body: <p>I'm using libgdx (com.badlogic.gdx.Game and Screens and that stuff) to make a game. I have the following problem: on desktop, when I close the window (from the cross on top), of course the application closes. But I would like to go back to menu screen and dispose there, since I do disposing of resources there (via asset manager). I have buttons for exiting in the game and if exiting is done that way, it's fine. The trouble is that the red cross can be pressed. So how could I handle disposing properly in that case?</p>
  
  <p>On the android version, I catch the back key and handle leaving different parts of the game and the whole game in my own way. And there it works OK.</p>
  
  <p>Another related question I have:</p>
  
  <p>On desktop the application cannot get stopped and then disposed (on it's own, without user explicitly exiting it) like the android version can (the android life cycle), right? So is it a good idea, if I do a temporary save on pause() and restore game state from that on resume(), that I don't restore on desktop (since the restoring isn't a complete restore and I don't want restoring to happen if, on desktop, the window is just minimized (as I noticed, pause()/resume() gets called when minimizing/restoring window )).</p>
  
  <p>Hope this wasn't too unclear :D. I've tried to google for answers but don't seem to find anything. Any help is much appreciated.</p>