title: Socket doesn't close after application exits if a launched process is open
body: <p>My C# .net application currently does the following (among other things):</p>
  
  <ol>
  <li>Creates a thread which opens a socket on a specific port and waits for an instruction.</li>
  <li>Message comes in, socket thread reads the message and raises an event.</li>
  <li>An event handler calls the necessary functions to parse the message and performs the necessary action, for instance, launching an application.</li>
  <li>The specified external "application" launches, asynchronously.</li>
  </ol>
  
  <p>When my application restarts, but the external application does not close, the socket doesn't seem to ever close. Then when I try to start up communication on that port again I get an error. However, as soon as I close the external application I am able to open a socket on that port.</p>
  
  <p>It seems like my program is not closing down properly. It should be killing the socket when it exits, however when the external process is running that socket never closes.</p>
  
  <p>Any ideas?</p>