diff --git a/src/main.c b/src/main.c
index cf2a0a92716ac8694e9cc52fbe70269215024712..e1fc8a391d570933d72ab742154e659cff549550 100644
--- a/src/main.c
+++ b/src/main.c
@@ -230,9 +230,9 @@ void exit_main()
   void cleanup_program();
 
   automatic_fatal="uLPC is exiting: ";
+  cleanup_objects();
   exit_signals();
   exit_lex();
-  cleanup_objects();
   cleanup_interpret();
   cleanup_added_efuns();
   free_all_call_outs();