title: How to do implement an OnExit like method in my XNA game?
body: <p>Is there any method for C# XNA games which detects if the user clicked on the cross button to close the program, or pressed the ALT+F4 keys to close .. ?</p>
  
  <p>The ALT+F4 keys can probably be detected from KeyBoardState, but how do I detect the clicking of the cross button to close the window ?</p>
  
  <p>I need this so that I can shut down all the threads running when the user closes the game through any means .. I currently have some threads still running when the close the game which makes the music still play :P</p>
  
  <p>Please note that the method has to be both Windows and Xbox 360 compatible, as the game is supposed to run on both these platforms (probably Zune too) ..</p>