code: def close(self):
          
          if self._closed:
              return
          self._closed = True
          self._writer.endElementNS((namespaces.xmlstream, "stream"), None)
          for prefix in self._nsmap_to_use:
              self._writer.endPrefixMapping(prefix)
          self._writer.endDocument()
          del self._writer
docs: Close the stream.
  
          The stream footer is sent and the internal structures are cleaned up.
  
          If the stream is already :attr:`closed`, this method does nothing.