diff --git a/DDG4/plugins/Geant4GDMLWriteAction.cpp b/DDG4/plugins/Geant4GDMLWriteAction.cpp
index e1209a4663afed8fb029003977b3bbb063ed4a04..ffb5ca17491c4c91b927ca21374ce0243576da17 100644
--- a/DDG4/plugins/Geant4GDMLWriteAction.cpp
+++ b/DDG4/plugins/Geant4GDMLWriteAction.cpp
@@ -74,6 +74,12 @@ namespace dd4hep {
 // Geant 4 includes
 #include "G4GDMLParser.hh"
 
+// C/C++ include files
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <memory>
+
 using namespace std;
 using namespace dd4hep;
 using namespace dd4hep::sim;
@@ -98,9 +104,6 @@ void Geant4GDMLWriteAction::installCommandMessenger()   {
   Callback cb = Callback(this).make(&Geant4GDMLWriteAction::writeGDML);
   m_control->addCall("write", "Write geometry to GDML file",cb);
 }
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
 
 /// Write geometry to GDML
 void Geant4GDMLWriteAction::writeGDML()   {
@@ -117,9 +120,9 @@ void Geant4GDMLWriteAction::writeGDML()   {
     warning("+++ GDML file %s already exists. Overwriting existing file.", m_output.c_str());
     ::unlink(m_output.c_str());
   }
-  G4GDMLParser parser;
+  unique_ptr<G4GDMLParser> parser(new G4GDMLParser());
   info("+++ Writing GDML file: %s", m_output.c_str());
-  parser.Write(m_output, context()->world());
+  parser->Write(m_output, context()->world());
 }
 
 #include "DDG4/Factories.h"
diff --git a/examples/CLICSiD/scripts/CLIC_GDML.py b/examples/CLICSiD/scripts/CLIC_GDML.py
index fbcf9581cfb580e2cf149d035e676ecc46493a29..69a007e8312fc7c0630196b99414d09670f2b99d 100644
--- a/examples/CLICSiD/scripts/CLIC_GDML.py
+++ b/examples/CLICSiD/scripts/CLIC_GDML.py
@@ -29,8 +29,7 @@ def run():
   ui.Commands = [
     '/ddg4/Writer/Output CLICSiD.gdml',
     '/ddg4/Writer/OverWrite 1',
-    '/ddg4/Writer/write',
-    'exit'
+    '/ddg4/Writer/write'
     ]
   kernel.configure()
   kernel.initialize()