code: async def ensure_closed(self):
          
          if self._writer is None:
              # connection has been closed
              return
          send_data = struct.pack('<i', 1) + int2byte(COMMAND.COM_QUIT)
          self._writer.write(send_data)
          await self._writer.drain()
          self.close()
docs: Send quit command and then close socket connection