title: Pygame, pygame_menu - close after start and video system not initialized error
body: <p>I'm trying make Simon game. I'm beginner in programming.
  I have problem when i start program first time the menu starts. When i click on play and another play in submenu it starts main loop and game works properly.
  when i close the window it gives me an error:</p>
  <p><em><strong>pygame.display.flip()
  error: video system not initialized</strong></em></p>
  <p>When i start progam second time the window will start but it closes immediately without error message.</p>
  <p>And so it is still around:<br />
  Start first time -&gt; Start and with close error.<br />
  Start second time -&gt; Close window without error.<br />
  I checked some posts I checked some posts but it did'nt work.</p>
  <pre><code>
  import pygame as game
  import pygame_menu as game_menu
  
  print(game.font.get_fonts())
  
  
  game.init()
  
  game.font.init()
  
  game.mixer.init()
  
  
  WIDTH, HEIGHT = 900, 500
  
  
  FPS = 60
  
  
  window = game.display.set_mode((WIDTH, HEIGHT))
  
  game.display.set_caption(&quot;Simon v1.0&quot;)
  
  #FONTS
  
  Font = game.font.SysFont(&quot;Arial&quot;, 85)
  mainFont = game_menu.font.FONT_MUNRO
  titleFont = game_menu.font.FONT_8BIT
  titleBar = game_menu.widgets.MENUBAR_STYLE_UNDERLINE
  fontScore = game.font.SysFont(&quot;Arial&quot;, 35)
  FontLower = game.font.SysFont(&quot;Arial&quot;, 20)
  
  #Width for center
  # nameWidth, _ = Font.size(&quot;SIMON&quot;)
  pressWidth, _ = Font.size(&quot;Press space to start&quot;)
  overWidth, _ = Font.size(&quot;Gameover&quot;)
  #MENU THEME
  menuTheme = mytheme = game_menu.Theme(background_color=(0, 0, 0, 0),
                  title_background_color=(255, 255, 255, 255),
                  widget_padding = 15,
                  widget_font = mainFont,
                  widget_font_size = 20,
                  widget_font_color = (255, 255, 255),
                  title_font = titleFont,
                  title_bar_style = titleBar,
                  title_offset = (0, -10),
                  widget_box_border_width = 100,
                  title_font_color = (209, 212, 161))
  
  #Player name
  playerName = &quot;&quot;
  
  #colors
  radius = 100
  redCircle = (140,0,0)
  blueCircle = (0,0,140)
  yellowCircle = (140,140,0)
  greenCircle = (0,140,0)
  
  run = True
  gameOver = False
  gameState = 0
  score = 0
  
  def main():
  
      global run, gameState, colorR, colorG, colorB
  
  
      clock = game.time.Clock()  
      draw()
      while run == True:
          clock.tick(FPS)
          for event in game.event.get():
  
              if event.type == game.QUIT:
  
                 run = False
      game.quit() 
  
  def draw():
      global gameOver, overWidth
      
      window.fill((0,0,0))
      
      if gameState == 0:
          textPress = fontScore.render(&quot;Press space to start &quot;, 1, (255,255,255))
          window.blit(textPress, (WIDTH/2 - pressWidth/2,50))
      
      if gameOver:
          textGameOver = mainFont.render(&quot;Gameover&quot;, 1, (255,255,255))
          centerTitle = textGameOver.get_rect(center=(WIDTH/2,120))
          window.blit(textGameOver, centerTitle)
          
          textFinScore = fontScore.render(&quot;Your score is: &quot; + str(score), 1, (255,255,255))
          centerTitle = textFinScore.get_rect(center=(WIDTH/2,200))
          window.blit(textFinScore, centerTitle)
          
          textRestart = FontLower.render(&quot;Press space for restart&quot;, 1, (255,255,255))
          centerTitle = textRestart.get_rect(center=(WIDTH/2,300))
          window.blit(textRestart, centerTitle)
          
          textExit = FontLower.render(&quot;Press esc for exit from game&quot;, 1, (255,255,255))
          centerTitle = textExit.get_rect(center=(WIDTH/2,335))
          window.blit(textExit, centerTitle)
          
      else:
          game.draw.circle(window, redCircle, [(WIDTH/2), 240], radius, 40, draw_top_right = True)
          game.draw.circle(window, blueCircle, [(WIDTH/2), 250], radius, 40, draw_bottom_right = True)
          game.draw.circle(window, greenCircle, [(WIDTH/2)-10, 240], radius, 40, draw_top_left = True)
          game.draw.circle(window, yellowCircle, [(WIDTH/2)-10, 250], radius, 40, draw_bottom_left = True)  
          draw_score()
          
      game.display.update() 
      game.display.flip()
      
  def draw_score():
      textScore = fontScore.render(&quot;Score: &quot; + str(score), 1, (255,255,255))
      window.blit(textScore, (20,0))    
  
  def save_name(name):
      global playerName
      playerName = name
      print(playerName)
  
  def mainMenu():
      global top,menu,credi,play,topMenu
      
      Cred = &quot;Created by: &quot;
      
      menu = game_menu.Menu(300, 400, 'Simon', theme = menuTheme)
      credi = game_menu.Menu(300, 400, 'Simon', onclose = None, theme = menuTheme)
      play = game_menu.Menu(300, 400, 'Simon', onclose = None, theme = menuTheme)
      topMenu = game_menu.Menu(300, 400, 'Simon', onclose = None, theme = menuTheme)
      #Main menu
      menu.add.button(&quot;Play&quot;, play)
      menu.add.button(&quot;Top score&quot;)
      menu.add.button(&quot;Settings&quot;)
      menu.add.button(&quot;Credits&quot;, credi)
      menu.add.button(&quot;Quit&quot;, game_menu.events.EXIT)
      #Credit submenu
      credi.add_label(Cred, max_char = 0, font_size = 20)
      credi.add.button(&quot;Back&quot;, game_menu.events.BACK)
      
      #Play submenu
      play.add_label(&quot;Type your name&quot;, font_size = 20)
      play.add.text_input(&quot;Name : &quot;, default = '', input_underline = &quot;_&quot;, maxchar = 14, onchange = save_name, onreturn = save_name)
      play.add.button(&quot;Play&quot;, main)
      play.add.button(&quot;Back&quot;, game_menu.events.BACK)
      menu.mainloop(window)
  
  mainMenu()
  </code></pre>
  <p>Sorry for my bad english.
  And Thanks for your tips</p>