Finalizing the document