code: def close(self):
          
          if hasattr(self, "thread"):
              self.thread._exit = True
              self.thread.join(1000)
          if self._conn is not None:
              self._conn.close()
docs: Close the current connection and terminate the agent
          Should be called manually