title: Python pygame quit issue
body: <p>I'm trying to get my program to quit when the ESC key is pressed, but also if the windows exit button is clicked.</p>
  
  <p>Currently I have this code:</p>
  
  <pre><code>done = False
  while not done:
      for event in pygame.event.get():
          if event.type == pygame.KEYDOWN:
              if event.key == pygame.K_ESCAPE:
                  done = True
                  break # break out of the for loop
          elif event.type == pygame.QUIT:
              done = True
              break # break out of the for loop
      if done:
          break # to break out of the while loop
  
      # your game stuff
      for dict_containing_value in holdList:           
              i = dict_containing_value['value']
              #pygame.event.pump
              if (i=="("):
                  drawBracketBox(bracketColor, x, y)
                  label = myfont.render(str(i), 1, (0,0,0))
                  screen.blit(label, ((x+x)*50+25,(y+y+y)*50+25))
  
                  x=x+1
              elif (i==")"):
                  drawBracketBox(bracketColor, x, y)
                  label = myfont.render(str(i), 1, (0,0,0))
                  screen.blit(label, ((x+x)*50+31,(y+y+y)*50+25))
  
                  x=x+1
              elif (i=="IF"):
                  drawFunctionBox(functionColor, x, y)
                  label = myfont.render(str(i), 1, (0,0,0))
                  screen.blit(label, ((x+x)*50+21,(y+y+y)*50+22))
  
                  x=x+1
              elif (i=="sum"):
                  drawFunctionBox(functionColor, x, y)
                  label = myfont.render((i), 1, (0,0,0))
                  screen.blit(label, ((x+x)*50+14,(y+y+y)*50+22))
  
                  x=x+1
              elif (i=="+"):
                  drawOperatorCircle(opColor, x, y)
                  label = myfont.render(str(i), 1, (0,0,0))
                  screen.blit(label, ((x+x)*50+31,(y+y+y)*50+22))
  
                  x=x+1
              elif (i=="-"):
                  drawOperatorCircle(opColor, x, y)
                  label = myfont.render(str(i), 1, (0,0,0))
                  screen.blit(label, ((x+x)*50+32,(y+y+y)*50+22))
  
                  x=x+1
              elif (i=="*"):
                  drawOperatorCircle(opColor, x, y)
                  label = myfont.render(str(i), 1, (0,0,0))
                  screen.blit(label, ((x+x)*50+31,(y+y+y)*50+26))
  
                  x=x+1
              elif (i=="/"):
                  drawOperatorCircle(opColor, x, y)
                  label = myfont.render(str(i), 1, (0,0,0))
                  screen.blit(label, ((x+x)*50+32,(y+y+y)*50+22))
  
                  x=x+1
              else:
                  drawConstantBox(constColor, x, y)
                  label = myfont.render(str(i), 1, (0,0,0))
                  screen.blit(label, ((x+x)*50+14,(y+y+y)*50+22))
  
                  x=x+1
      pygame.display.update()
  </code></pre>
  
  <p>The current output is that continuously loops round my <code>for dict_containing_value in holdList:</code> loop which means that it prints out the output many times - which is not my desired result.</p>
  
  <p>Please see the picture below (top picture is my current result, buttom is my desired result)
  <img src="https://i.stack.imgur.com/AnB0C.png" alt="enter image description here"></p>