code: def _close(self, status, do_callbacks=True):
          
          if self.is_closed:
              self._status = status
              return
          self._status = Client.CLOSED
  
          # Stop background tasks
          yield self._end_flusher_loop()
  
          if self._ping_timer is not None and self._ping_timer.is_running():
              self._ping_timer.stop()
  
          if not self.io.closed():
              self.io.close()
  
          # Cleanup subscriptions since not reconnecting so no need
          # to replay the subscriptions anymore.
          for ssid, sub in self._subs.items():
              self._subs.pop(ssid, None)
              self._remove_subscription(sub)
  
          if do_callbacks:
              if self._disconnected_cb is not None:
                  self._disconnected_cb()
              if self._closed_cb is not None:
                  self._closed_cb()
docs: Takes the status on which it should leave the connection
          and an optional boolean parameter to dispatch the disconnected
          and close callbacks if there are any.