diff --git a/pgadmin/frm/events.cpp b/pgadmin/frm/events.cpp
index 9e0708d..fc7ccc8 100644
--- a/pgadmin/frm/events.cpp
+++ b/pgadmin/frm/events.cpp
@@ -155,6 +155,8 @@ void frmMain::OnClose(wxCloseEvent &event)
 {
 	wxWindow *fr;
 	windowList::Node *node;
+	// Clean up the memory allocated by the library ( libxml2 )
+	xmlCleanupParser();
 	while ((node = frames.GetFirst()) != NULL)
 	{
 		fr = node->GetData();
diff --git a/pgadmin/frm/frmReport.cpp b/pgadmin/frm/frmReport.cpp
index 7edd1d5..d727761 100644
--- a/pgadmin/frm/frmReport.cpp
+++ b/pgadmin/frm/frmReport.cpp
@@ -1143,7 +1143,6 @@ cleanup:
 	//  xmlFreeDoc(ssDoc);
 
 	xsltCleanupGlobals();
-	xmlCleanupParser();
 
 	wxEndBusyCursor();
 
