title: Thread persists after application termination due to AutoResetEvent signal in WaitOne state
body: <p>I have an application that uses an AutoResetEvent (WaitOne/Set) in a queue for processing messages.  I'm noticing that when I terminate the a debug session from Visual Studio (Shift+F5) the original process for the application hangs around (but not always).  I manually re-attach the debugger to the process, and see it has single thread stuck on WaitHandle.WaitOne.</p>
  
  <p>So my question is, what is the correct way to terminate threads that may be in a WaitOne state?</p>
  
  <p>The first answer that sprang to mind was listen to the Application Exit event and doing a Set there, but I wasn't sure if this event was called reliably after these debug sessions, or if there is a more standard practice that I am not aware of.</p>
  
  <p>And, as a second question, would you handle this differently for the application running in 'production' mode?</p>