title: Stopping a While loop and quitting script in Python
body: <p>I am using Sikuli the OCR testing library. In my Python script I am looking for one of two possible images to appear. When one of them does appear, if chooses that object.</p>
  
  <p>However, I would like for the script to end. It doesn't. I've tried <code>quit()</code> and <code>exit()</code> but that isn't doing it. It is working fine, beside the stop of the while loop and completing the script.</p>
  
  <pre><code>while True:
      if exists ("lose.png"):
          click ("lose.png")
          print ("***** YOU LOSE! *****")
      if exists ("win.png"):
          click ("win.png")
          print ("***** YOU WIN! *****")
      StopIteration
  
  quit()
  </code></pre>