code: @Override
      public void closeFile() throws JournalException {
          try {
              super.testStateChange(State.FILE_CLOSED);
              parent.writeDocumentTrailer(xmlWriter);
              xmlWriter.close();
  
              /*
               * SOME implementations of XMLWriter do not close all resources, so
               * we need to close the rmi manually just in case.
               */
              try {
                  writer.close();
              } catch (IOException e) {
                  throw new JournalException(e);
              }
              super.setState(State.FILE_CLOSED);
          } catch (XMLStreamException e) {
              throw new JournalException(e);
          }
      }
docs: check state, write the file closing, close/flush the writer, send the
  close request, set state.