diff --git a/coordinator/ProcessorUtils.py b/coordinator/ProcessorUtils.py
index 817d8c407ae06552ed856f24f91b9e93d0843c5e..c0683649998b5be3cd60f92251e912978095bf33 100644
--- a/coordinator/ProcessorUtils.py
+++ b/coordinator/ProcessorUtils.py
@@ -208,14 +208,14 @@ def endScript(
     if not premature:
 
         logger.info(f'Script finished!')
-
+        exit_code = 0
     else:
 
         logger.info(f'Script finished prematurely')
+        exit_code = 1
 
     logger.info(f'--------')
-
-    sys.exit()
+    sys.exit(exit_code)
 
 def endJob(status,ignore_inprogress=False,**kwargs):