docs: protected void afterEndDocument() {
          depth = 0;
          final Set<StackState> state = scopeState.getFirst();
          if (state.contains(StackState.WROTE_MARKUP)
                  && !state.contains(StackState.WROTE_DATA)) { // but not data
              try {
                  final String indent = getLineSeparator() + StringUtils.repeat("  ", 0);
                  final Characters indentEvent = xmlEventFactory.createCharacters(indent);
                  wrappedWriter.add(indentEvent);
              } catch (Exception ignored) {
              }
          }
          scopeState.clear();
          scopeState.push(EnumSet.noneOf(StackState.class)); // start fresh
      }