<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def shutdown(self):
 """ Request broker gracefully disconnect streams and stop. Safe to call from any thread. """

        _v and LOG.debug('%r.shutdown()', self)
        def _shutdown():
            self._alive = False
        if self._alive and not self._exitted:
            self.defer(_shutdown)