title: SWT: cleaning up before application exit
body: <p>What is the best way for an SWT application to clean up resources before application exit? I see two options:</p>
  
  <p>1) Add a DisposeListener to main window (or better, to the <code>Display</code>). Will it get run if an uncaught exception happens?</p>
  
  <p>2) Use a <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html#addShutdownHook%28java.lang.Thread%29" rel="nofollow noreferrer">shutdown hook</a>. Any problems to be aware of there which aren't mentioned in <a href="http://java.sun.com/j2se/1.4.2/docs/guide/lang/hook-design.html" rel="nofollow noreferrer">Design of the Shutdown Hooks API</a>?</p>