code: def stop(self):
          
          if not self.is_started:
              raise ConnectionError("Client is already stopped")
  
          if self.takeout_id:
              self.send(functions.account.FinishTakeoutSession())
              log.warning("Takeout session {} finished".format(self.takeout_id))
  
          Syncer.remove(self)
          self.dispatcher.stop()
  
          for _ in range(self.DOWNLOAD_WORKERS):
              self.download_queue.put(None)
  
          for i in self.download_workers_list:
              i.join()
  
          self.download_workers_list.clear()
  
          for _ in range(self.UPDATES_WORKERS):
              self.updates_queue.put(None)
  
          for i in self.updates_workers_list:
              i.join()
  
          self.updates_workers_list.clear()
  
          for i in self.media_sessions.values():
              i.stop()
  
          self.media_sessions.clear()
  
          self.is_started = False
          self.session.stop()
  
          return self
docs: Use this method to manually stop the Client.
          Requires no parameters.
  
          Raises:
              ``ConnectionError`` in case you try to stop an already stopped Client.