code: def stop(self, timeout=None):
          
          ioloop = getattr(self, 'ioloop', None)
          if not ioloop:
              raise RuntimeError('Call start() before stop()')
          if timeout:
              if get_thread_ident() == self.ioloop_thread_id:
                  raise RuntimeError('Cannot block inside ioloop')
              self._running.wait_with_ioloop(self.ioloop, timeout)
  
          def _cleanup():
              self._running.clear()
              self._disconnect()
          self._ioloop_manager.stop(timeout=timeout, callback=_cleanup)
docs: Stop a running client (from another thread).
  
          Parameters
          ----------
          timeout : float in seconds
             Seconds to wait for client thread to have *started*.