code: def terminate_pool(self):
          
  
          if self.pool is not None:
              self.pool.terminate()
              self.pool.join()
              del(self.pool)
              self.pool = None
docs: Terminate and close the multiprocessing pool if necessary.