<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def connection_lost(self, exc):
 """ Gets called when the connection to the gateway is lost. Tear down and clean up the protocol object. """

        _LOGGER.error("Disconnected: %s", exc)
        self.connected = False
        self.transport.close()
        if self._report_task is not None:
            self._report_task.cancel()
        self._msg_task.cancel()
        for q in [self._cmdq, self._updateq, self._msgq]:
            while not q.empty():
                q.get_nowait()
        self.status = {}