code: def close(self):
          
          self.stopped.set()
          for event in self.to_be_stopped:
              event.set()
          if self._receiver_thread is not None:
              self._receiver_thread.join()
          self._socket.close()
docs: Stop the client.