title: Cannot close socket pressing Ctrl+C
body: <p>I am trying to close a socket when the user presses ctrl-c. This works fine if the socket is still doing something. But when the socket is done with it's job and is doing nothing and I press ctrl-c nothing happens. By the way I am using windows 8.1.</p>
  
  <p>Here is my code:</p>
  
  <pre><code># close socket ctrl-c
  from signal import signal, SIGINT
  def sigint_received(signum, frame):
      s.close()
      exit(0)
  
  # register SIGINT callback
  signal(SIGINT, sigint_received)
  </code></pre>
  
  <p>When I try this code I have the same issue :</p>
  
  <pre><code>OriginalExceptHook = sys.excepthook
  def NewExceptHook(type, value, traceback):
      if type == KeyboardInterrupt:
          exit("\nExiting.")
      else:
          OriginalExceptHook(type, value, traceback)
      sys.excepthook = NewExceptHook
  </code></pre>
  
  <p>Anyone knows what's wrong?</p>