code: def close(self, reason=None):
          
          with self._closing:
              if self._closed:
                  return
  
              self._websocket.close()
  
              self._consumer.join()
              self._consumer = None
  
              self._websocket = None
              self._closed = True
              for cb in self._close_callbacks:
                  cb(self, reason)
docs: Stop consuming messages and perform an orderly shutdown.
  
          If ``reason`` is None, then this is considered a regular close.