code: def cleanup(self):
          
          if self.transport:
              self.transport.close()
              self.transport = None
          if self.task:
              self.task.cancel()
              self.task = None
docs: Method to call to cleanly terminate the connection to the device.