code: def shutdown(self):
          
          self.stopped.set()
  
          if hasattr(self.api, "shutdown"):
              self.api.shutdown()
  
          for thread in self.thread.values():
              thread.join()
docs: Executed on shutdown of application