diff --git a/ayrton/__init__.py b/ayrton/__init__.py
index <HASH>..<HASH> 100644
--- a/ayrton/__init__.py
+++ b/ayrton/__init__.py
@@ -198,5 +198,6 @@ def run (code, globals, locals):
     runner.run ()
 
 def main (script=None, file=None, **kwargs):
+    global runner
     runner= Ayrton (script=script, file=file, **kwargs)
     runner.run ()
@ revert reference to global.