title: How does the JVM terminate daemon threads? or How to write daemon threads that terminate gracefully
body: <p>Hypothetical scenario:<br>
  I have a daemon thread responsible for some I/O, the main thread finishes and returns, and the JVM decides to terminate my daemon thread.</p>
  
  <p>How does it do so? Interrupt? Finalize? How can I code my daemon thread so that it reacts gracefully when terminated?</p>