code: public final void close() throws IllegalStateException, IOException {
  
          // Check state
          if (_state != XMLEventListenerStates.START_TAG_OPEN && _state != XMLEventListenerStates.WITHIN_ELEMENT && _state != XMLEventListenerStates.AFTER_ROOT_ELEMENT) {
              throw new IllegalStateException("getState() == " + _state);
          }
  
          while (_elementStackSize > 0) {
              endTag();
          }
  
          // State has changed, check
          checkInvariants();
      }
docs: Closes all open elements. After calling this method, only the {@link #whitespace(String)}
  method can be called.
  <p />
  If you would like to flush the output stream as well, call {@link #endDocument()} instead.
  
  @throws IllegalStateException if <code>getState() != {@link #START_TAG_OPEN} &amp;&amp; getState() !=
  {@link #WITHIN_ELEMENT} &amp;&amp; getState() != {@link #AFTER_ROOT_ELEMENT}</code>
  @throws IOException           if an I/O error occurs; this will set the state to {@link #ERROR_STATE}.