title: Java Shutdown function not executing
body: <p>Within the main() of my application I have the following code to back up data so it doesn't get lost in the event of a system shut down.</p>
  
  <pre><code>    //add hook to trigger Production Shutdown sequence
      Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
          public void run() {
              Production.shutdown();
          }
      }));
  </code></pre>
  
  <p>However, whether I press the <code>Stop</code> button in my IDE or rely on input via the log (code shown below) it never seems to save data to the database or write any logs to the console.</p>
  
  <pre><code>    ctx.deploy(server);
  
      server.start();
  
      //start the production process
      Production.init();
  
      System.in.read();
      server.stop();
  </code></pre>
  
  <p>How come this shutdown function is not being executed?</p>