diff --git a/beat/core/agent.py b/beat/core/agent.py
index 076902b6ea5a58bfae72455bbb2d964808fc3847..623f494bdd79035020fb217f7f124869bd539f6c 100755
--- a/beat/core/agent.py
+++ b/beat/core/agent.py
@@ -74,6 +74,10 @@ class Server(MessageHandler):
     ))
 
 
+  def destroy(self):
+    self.context.destroy()
+
+
   def __str__(self):
     return 'Server(%s)' % self.address
 
@@ -367,6 +371,7 @@ class Agent(object):
       self.db_process.rm()
       self.db_process = None
 
+    self.server.destroy()
     self.server = None
     return retval
 
diff --git a/beat/core/execution.py b/beat/core/execution.py
index 466d30905d33bce44821590f68a02f1107c7402d..555b0296229ee3bea538df29ee5f527074bb15cc 100755
--- a/beat/core/execution.py
+++ b/beat/core/execution.py
@@ -152,6 +152,7 @@ class Executor(object):
     self.output_list = None
     self.data_sinks = []
     self.data_sources = []
+    self.context = None
 
     # runs validation if required
     self.errors = []
@@ -183,6 +184,7 @@ class Executor(object):
     self.output_list = None
     self.data_sinks = []
     self.data_sources = []
+    self.context = None
     self.db_address = None
 
     if not isinstance(data, dict): #user has passed a file pointer
@@ -268,6 +270,10 @@ class Executor(object):
     self.data_sources = []
     self.agent = None
 
+    if self.context is not None:
+        self.context.destroy()
+        self.context = None
+
 
   def _prepare_inputs(self):
     """Prepares all input required by the execution."""