diff --git a/contrib/onelab/python/onelab.py b/contrib/onelab/python/onelab.py
index 61de45fd85df64cf589bc876f543e021875ffe42..b658cf7f58fbb0d30e5f411803d36b5b7351ec9b 100755
--- a/contrib/onelab/python/onelab.py
+++ b/contrib/onelab/python/onelab.py
@@ -328,9 +328,14 @@ class client :
     self.action = self.getString('python/Action')
     self.setNumber('IsPyMetamodel',value=1,visible=0)
     if self.action == "initialize": exit(0)
-  
-  def __del__(self) :
-    self._wait_on_subclients()
+
+  def finalize(self) : #code aster python interpreter does not call the destructor at exit, it is necessary to call finalize() epxlicitely
     if self.socket :
+      self._wait_on_subclients()
       self._send(self._GMSH_STOP, 'Goodbye!')
       self.socket.close()
+      self.socket = None
+    
+  
+  def __del__(self) :
+    finalize()