title: Quit function is not working in pygame
body: <p>I want the system to exit when I click the "x" on the window of pygame. I want to be able to call the <code>quit_game</code> function whenever I need to. So if the user does quit, it actually quits. I have tried <code>sys exit</code> and <code>pygame.quit()</code>, but I haven't been able to successfully implement those. Right now I just have the quit function built into the intro screen. I am using python 3.4.3. Here is the code.</p>
  
  <pre><code>import math
  import random
  import time
  import pygame
  import sys
  import glob
  pygame.init()
  move=0
  FPS=60
  blue=(0,0,255)
  white=(255,255,255)
  black=(0,0,0)
  green=(0,155,0)
  display_width=800
  display_height=600
  gamedisplay=pygame.display.set_mode((display_width,display_height))
  pygame.display.set_caption('Stacker')
  clock=pygame.time.Clock()
  speed=2
  smallfont=pygame.font.SysFont("Arial",int(display_width/32))
  mediumfont=pygame.font.SysFont("Arial",int(display_width/16))
  largefont=pygame.font.SysFont("Arial",int(display_width/10))
  gamedisplay.fill(green)
  block=display_height/12
  pygame.display.update()
  def quit_game():
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              pygame.quit()
              sys.exit()
              quit()
  def intro_screen():
      welcome_message = mediumfont.render(str("Welcome to Stacker!!!"), True,black)
      gamedisplay.blit(welcome_message,(display_width/4,display_height/40))
      how_to_play_1=smallfont.render(str("Your goal is to get to the major prize bar"),True,black)
      gamedisplay.blit(how_to_play_1,(display_width/3.619909502,display_height/2))
      how_to_play=smallfont.render(str("Press the space bar to stop the shape"),True,black)
      gamedisplay.blit(how_to_play,(display_width/3.48583878,display_height/(12/7)))
      quit_game()
      pygame.display.update()
  def middle_block():
      pygame.draw.rect(gamedisplay, blue,(display_width/(32/15),display_height-block,block,block))
      pygame.display.update()
  def left_block():
      pygame.draw.rect(gamedisplay, blue,(display_width/(32/13),display_height-block,block,block))
      pygame.display.update()
  def right_block():
      pygame.draw.rect(gamedisplay, blue,(display_width/(32/17),display_height-block,block,block))
      pygame.display.update()
  def major_screen():
      major_message = mediumfont.render(str("Major Prize Here!"), True,black)
      gamedisplay.blit(major_message,(display_width/(10/3),display_height/40))
      pygame.display.update()
  intro_screen()
  pygame.time.delay(8000)
  gamedisplay.fill(green)
  major_screen()
  pygame.draw.rect(gamedisplay, blue,(display_width-display_width,display_height/8,display_width,display_height/60))
  pygame.draw.rect(gamedisplay, blue,(display_width-display_width,display_height/2.4,display_width,display_height/60))
  middle_block()
  left_block()
  right_block()
  pygame.display.update()
  </code></pre>