title: Close the program using keyboard interrupt in python
body: <p>I am working on Python 2.7 on windows. </p>
  
  <p>How to close the program by keyboard interrupt in python. </p>
  
  <p>I made some code but it asks me every time to give a input and then perform something according to that. 
  I want that the code should not ask me every time and at any random time when I give the input it should perform the corresponding action
  (for my case close the program)</p>
  
  <pre><code>while 1:
  var = raw_input("enter a to stop:  ")
       if var == 'a':
         break
  
  exit()   
  </code></pre>