title: What happens if System.exit is called from a shutdown hook?
body: <p>I have a rather complicated shutdown in Java - there's a lot of clean up work to do.  In particular I'm trying to figure out how to error handle from a shutdown hook thread.  My code includes this currently:</p>
  
  <pre><code>try {
      return shutdownPromise = doShutdown();
  }
  catch (Throwable exc) {
      logger.error("An exception was thrown while shutting down the application.", exc);  
      System.exit(1);
      return null;
  }
  </code></pre>
  
  <p>When I originally wrote this I essentially thought, an error in shutdown should just go straight to <code>exit</code>. But <code>exit</code> is not so low level; it calls the shutdown hooks.</p>
  
  <p>So I thought - </p>
  
  <ol>
  <li>What does calling exit from a shutdown hook do?</li>
  <li>What is the right way to error handle from a shutdown hook?</li>
  </ol>