Add support for writing the DocumentEnd-Tag after writing a Document.

Feel free to criticise.