<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def stop_listener_thread(self):
 """ Kills sync_thread greenlet before joining it """

        # when stopping, `kill` will cause the `self.api.sync` call in _sync
        # to raise a connection error. This flag will ensure it exits gracefully then
        self.should_listen = False
        if self.sync_thread:
            self.sync_thread.kill()
            self.sync_thread.get()
        if self._handle_thread is not None:
            self._handle_thread.get()
        self.sync_thread = None
        self._handle_thread = None