title: How could I close tqdm_gui?
body: <p>I'm new to parallel processing. In my software I want to do some parser jobs parallel to speed up and I want to inform the user that the parsing jobs are still running. I found tqdm to do this job and I'm having now the problem to close the figure from tqdm_gui.</p>
  
  <p>Looking around I found this post from  Dan Shiebler:
  <a href="http://danshiebler.com/2016-09-14-parallel-progress-bar/" rel="nofollow noreferrer">http://danshiebler.com/2016-09-14-parallel-progress-bar/</a></p>
  
  <p>I change this code a little bit to use it with the GUI from tqdm. See the code snippet below.</p>
  
  <p>If I call the parallel_process_gui again, there is still an (old) figure behind the (new) one. How could I close this, both or all figures?</p>
  
  <p>What I have already tried is to change the leave flag from True to False </p>
  
  <pre><code>kwargs = {
              'total': len(futures),
              'unit': 'it',
              'unit_scale': True,
              'leave': True,
              'desc': desc
          }
  </code></pre>
  
  <p>and try to close the figure with</p>
  
  <pre><code>tqdm.tqdm_gui.close()
  </code></pre>
  
  <p>with no luck</p>
  
  <p>The code snippet:</p>
  
  <pre><code>
  import tqdm
  from concurrent.futures import ProcessPoolExecutor, as_completed
  from time import sleep
  
  def parallel_process_gui(array,
                           function,
                           n_jobs=16,
                           desc='process',
                           use_kwargs=False,
                           front_num=3):
      """
          A parallel version of the map function with a progress bar.
  
          http://danshiebler.com/2016-09-14-parallel-progress-bar/
  
          Args:
              array (array-like): An array to iterate over.
              function (function): A python function to apply to the elements of array
              n_jobs (int, default=16): The number of cores to use
              use_kwargs (boolean, default=False): Whether to consider the elements
              of array as dictionaries of keyword arguments to function
              front_num (int, default=3): The number of iterations to run serially
              before kicking off the parallel job. Useful for catching bugs
  
          Returns:
              [function(array[0]), function(array[1]), ...]
      """
      # We run the first few iterations serially to catch bugs
      if front_num &gt; 0:
          front = [function(**a) if use_kwargs else function(a)
                   for a in array[:front_num]]
      else:
          front = []
      # If we set n_jobs to 1, just run a list comprehension. This is useful for
      # benchmarking and debugging.
      if n_jobs == 1:
          return front + [function(**a) if use_kwargs else function(a)
                          for a in tqdm.tqdm_gui(array[front_num:])]
      # Assemble the workers
      with ProcessPoolExecutor(max_workers=n_jobs) as pool:
          # Pass the elements of array into function
          if use_kwargs:
              futures = [pool.submit(function, **a) for a in array[front_num:]]
          else:
              futures = [pool.submit(function, a) for a in array[front_num:]]
          kwargs = {
              'total': len(futures),
              'unit': 'it',
              'unit_scale': True,
              'leave': True,
              'desc': desc
          }
          # Print out the progress as tasks complete
          for f in tqdm.tqdm_gui(as_completed(futures), **kwargs):
              pass
  
      out = []
      # Get the results from the futures.
      for i, future in tqdm.tqdm_gui(enumerate(futures)):
          try:
              out.append(future.result())
          except Exception as e:
              out.append(e)
  
      return front + out
  
  
  def get_big_number(i, how_many):
      '''
      only for tests. Generates a big number
      :param i: factor
      :param how_many: iterations of additions
      '''
      return sum([100000 * 100000 * i for i in range(how_many)])
  
  
  if __name__ == '__main__':
      '''
      build an array (arr) of dicts. Each dict has all parameters (i, how_many)
      of function (get_big_number) for parallel processing. in this example
      1000 processes are started
      '''
      arr = [{'i': i, 'how_many': 100000 if i % 2 else 220000}
             for i in range(10)]
      # show 1st 10 dicts
      for i in range(10):
          print (i, " ", arr[i])
  
      list_of_big = parallel_process_gui(
          arr,
          get_big_number,
          desc="progress 1",
          front_num=0,
          use_kwargs=True)
  
      arr = [{'i': i, 'how_many': 100000 if i % 2 else 220000}
             for i in range(1000)]
  
      #run it again, now there is one (old) window in background of 
      #a new progressbar 
      list_of_big = parallel_process_gui(
          arr,
          get_big_number,
          desc="progress 2",
          front_num=0,
          use_kwargs=True)
  
      # show 1st 10 results
      for i in range(10):
          print (i, " ", list_of_big[i])
  
      # show last 10 results
      for i in range(990, 1000):
          print (i, " ", list_of_big[i])
  
      sleep(10)
  </code></pre>
  
  <p>I know that the tqdm_gui is still experimental/alpha, but I expect that the progressbar is closed after doing the parsing jobs. </p>
  
  <p>Any help would appreciated.</p>
  
  <p>Thomas</p>