Fix a mem leak in TreeWriter

Saxon's Receiver instance was not closed in TreeWriter. This change closes it in the TreeWriter#endDocument method.