code: @Override
    public final void close()
        throws IOException {
      try {
        // end collection
        writer.writeEndCollection()
            .writeEndDocument()
            .close();
      } catch (XMLStreamException e) {
        throw new IOException(e.getMessage());
      }
    }
docs: Closes the writer, flushing it first. Once the writer has been closed,
  further writeCollection() invocations will cause an IOException to be
  thrown. Closing a previously closed writer has no effect.