title: AIR SocketServer cleanup? How to close when app quits?
body: <p>I have a simple AIR app that listens on a socket using the SocketServer class.</p>
  
  <p>I have the following code when I first start up the app:</p>
  
  <pre><code>if( serverSocket.bound ) 
          {
              serverSocket.close();
              serverSocket = new ServerSocket();
  
          }
          serverSocket.bind( parseInt( localPort ), localIP );
          serverSocket.addEventListener( ServerSocketConnectEvent.CONNECT, onConnect );
          serverSocket.listen();
  </code></pre>
  
  <p>However I find that if I try to test my movie after making some quick changes, I can't bind to the same address:port. I'm guessing that somehow that the port is still occupied. I get a "Operation attempted on invalid socket" error.</p>
  
  <p>But if I wait a bit and then test my movie, I can bind to the address:port.</p>
  
  <p>The close() is not taking affect. Can I try to close() this when the user decides to exit the app? Is there some sort of event that allows me to do something before the app quits?</p>