code: def close(self):
          
          if (self._smachine.state == State.CLOSING or
                  self._smachine.state == State.CLOSED):
              return
          self._writer.close()
          if self._transport.can_write_eof():
              self._transport.write_eof()
          if self._smachine.state == State.STREAM_HEADER_SENT:
              # at this point, we cannot wait for the peer to send
              # </stream:stream>
              self._close_transport()
          self._smachine.state = State.CLOSING
docs: Close the XML stream and the underlying transport.
  
          This gracefully shuts down the XML stream and the transport, if
          possible by writing the eof using :meth:`asyncio.Transport.write_eof`
          after sending the stream footer.
  
          After a call to :meth:`close`, no other stream manipulating or sending
          method can be called; doing so will result in a
          :class:`ConnectionError` exception or any exception caused by the
          transport during shutdown.
  
          Calling :meth:`close` while the stream is closing or closed is a
          no-op.