title: How to stop java process gracefully?
body: <p>How do I stop a Java process gracefully in Linux and Windows?</p>
  
  <p>When does <code>Runtime.getRuntime().addShutdownHook</code> get called, and when does it not?</p>
  
  <p>What about finalizers, do they help here?</p>
  
  <p>Can I send some sort of signal to a Java process from a shell?</p>
  
  <p>I am looking for preferably portable solutions.</p>