title: How to shutdown local tomcat server when closing browser window?
body: <p>I hava a web app running on a local tomcat server.</p>
  
  <p>When the user starts the app (via desktop shortcut) the server starts and the app is opened in a browser window.
  But when the user just clicks on the close button to stop the application the server is still running in the background - that's annoying.</p>
  
  <p>I tried to utilize the "unonload" and "onbeforeunload" events from javascript but unfortunately these events are also fired on some other requests in the app. 
  So I can't use them, except I do a lot of refactoring.</p>
  
  <p>Does anyone have an idea for a possible solution?</p>
  
  <p>Btw, what I find interesting is the behaviour of Visual Studio when debugging a web application. When I close the browser window Visual Studio also gets a trigger to stop debug mode. So it seems it somehow notices the close event of the browser window, which would be exactly what I need. But I don't know how they do it...</p>