Since it's a ugly COM object I think you'll need to do

pXMLDocument->Release();

each time you are done with the document.