def cleanup(self):
        """Method to call to cleanly terminate the connection to the device.
        """
        if self.transport:
            self.transport.close()
            self.transport = None
        if self.task:
            self.task.cancel()
            self.task = None
        for light in self.lights.values():
            light.cleanup()
        self.lights = {}