title: how to avoid this error (Error : display Surface quit ) when rendering open-AIgym?
body: <p>I am trying to solve the mountain car problem in AI gym, but when I use <code>env. render()</code>it works the first time, but when I try to render the simulation again after 2000 runs it gives the below error ( error: display Surface quit). How can I avoid this error?</p>
  <p>I am using windows, and I am running the code on a jupyter notebook.</p>
  <pre><code>import gym
  import numpy as np 
  import sys
  
  #Create gym environment.
  discount = 0.95
  Learning_rate = 0.01
  episodes = 25000
  SHOW_EVERY = 2000
      
  env = gym.make('MountainCar-v0')
  
  discrete_os_size = [20] *len(env.observation_space.high)
  discrete_os_win_size = (env.observation_space.high - env.observation_space.low)/ discrete_os_size
  q_table = np.random.uniform(low=-2, high=0, size=(discrete_os_size + [env.action_space.n]))
  
  # convert continuous state to discrete state 
  def get_discrete_state(state):
      discrete_State = (state - env.observation_space.low) / discrete_os_win_size
      return tuple(discrete_State.astype(int))
  
  
  
  
  for episode in range(episodes):
      
      if episode % SHOW_EVERY == 0:
          render = True
          print(episode)
      else:
          render = False
  
      ds = get_discrete_state(env.reset())
      done = False
      while not done:
          action = np.argmax(q_table[ds])
          new_state, reward, done, _ = env.step(action)
          new_discrete_state = get_discrete_state(new_state)
          
          if episode % SHOW_EVERY == 0:
              env.render()
  
  
          if not done:
              max_future_q = np.max(q_table[new_discrete_state])
              current_q_value = q_table[ds + (action, )]
              new_q = (1-Learning_rate) * current_q_value + Learning_rate * (reward + 
                   discount * max_future_q )
              q_table[ds + (action, )] = new_q
  
          elif new_state[0] &gt;= env.goal_position:
              q_table[ds + (action, )] = 0
  
          ds = new_discrete_state
          
     
  
      env.close()
  </code></pre>