title: Python selenium CTRL+C closes chromedriver
body: <p>How can I catch CTRL+C (a KeyboardInterrupt) without causing the chromedriver to close.
  It closes the chromedriver when I run my script.py through cmd.</p>
  
  <pre><code>driver = webdriver.Chrome()
  try:
      while True:
          #do stuff with chromedriver
  except KeyboardInterrupt:
      print "User pressed CTRL + C"
      #do other stuff with chromedriver
  </code></pre>
  
  <p>It does catch the KeyboardInterrupt in my script, thus my script continues but the chromedriver also gets it and close itself.</p>
  
  <p><strong>EDIT 1:</strong><br>
  The solution <a href="https://stackoverflow.com/questions/18499497/how-to-process-sigterm-signal-gracefully">here</a> doesn't work when you run the script through CMD or when you freeze the script with Pyinstaller and run it (<code>IOError: [Errno 4] Interrupted function call</code>)</p>
  
  <p><strong>EDIT 2:</strong><br>
  I also tried by making the script ignore the Errno 4 (using <code>try</code> and <code>except Exception</code>) but still has the same result (chromedriver closes) so in short, <a href="https://stackoverflow.com/questions/18499497/how-to-process-sigterm-signal-gracefully">this solution</a> does not help at all.</p>