title: Scala shutdown hooks never running?
body: <p>The scaladoc for <code>sys.addShutdownHook</code> says <code>shutdown hooks are NOT guaranteed to be run</code>. Now this is entirely reasonable, as the JVM can hardly run shutdown hooks if you send the JVM a SIGKILL, or whatever the Windows equivalent is.</p>
  
  <p>However shutdown hooks added with <code>sys.addShutdownHook</code> never seem to run, although those run with <code>Runtime.getRuntime.addShutdownHook</code> do.</p>
  
  <p>A test -</p>
  
  <pre><code>scala&gt; val t = new Thread { override def run = println("hi!") }
  t: java.lang.Thread = Thread[Thread-4,5,main]
  
  scala&gt; Runtime.getRuntime.addShutdownHook(t)
  
  scala&gt; hi!
  george@george-MacBook:~$ scala
  </code></pre>
  
  <p>(Skipped the startup message)</p>
  
  <pre><code>scala&gt; val t = new Thread { override def run = println("hi!") }
  t: java.lang.Thread = Thread[Thread-4,5,main]
  
  scala&gt; sys.addShutdownHook(t.run _)
  res0: scala.sys.ShutdownHookThread = Thread[shutdownHook1,5,main]
  
  scala&gt; george@george-MacBook:~$
  </code></pre>
  
  <p>The documentation says "The hook is automatically registered: the returned value can be ignored" so it's not that we're supposed to add the thread returned by <code>sys.addShutdownHook</code>
   (and at any rate that causes "IllegalArgumentException: Hook previously registered" to be thrown).</p>
  
  <p>Also, calling run on thread returned by addShutdownHook doesn't seem to do anything, which is suspicious.</p>