code: def shutdown(self, wait=False):
          
          LOG.debug('%r.shutdown() sending SHUTDOWN', self)
          latch = mitogen.core.Latch()
          mitogen.core.listen(self, 'disconnect', lambda: latch.put(None))
          self.send(
              mitogen.core.Message(
                  handle=mitogen.core.SHUTDOWN,
              )
          )
  
          if wait:
              latch.get()
          else:
              return latch
docs: Arrange for the context to receive a ``SHUTDOWN`` message, triggering
          graceful shutdown.
  
          Due to a lack of support for timers, no attempt is made yet to force
          terminate a hung context using this method. This will be fixed shortly.
  
          :param bool wait:
              If :data:`True`, block the calling thread until the context has
              completely terminated.
  
          :returns:
              If `wait` is :data:`False`, returns a :class:`mitogen.core.Latch`
              whose :meth:`get() <mitogen.core.Latch.get>` method returns
              :data:`None` when shutdown completes. The `timeout` parameter may
              be used to implement graceful timeouts.