diff --git a/src/module.c b/src/module.c
index 306e724e9fd6e4fbb41cb69fe305fe75a9501089..9e53d003e5225e61aa6e2d7fa5e240d6fdc2a923 100644
--- a/src/module.c
+++ b/src/module.c
@@ -157,7 +157,6 @@ static void exit_builtin_modules(void)
    * THREADS_ALLOW/DISALLOW are NOPs beyond this point. */
   th_cleanup();
 #endif
-  free_all_pike_list_node_blocks();
 
   exit_pike_security();
   free_svalue(& throw_value);
@@ -360,6 +359,7 @@ static void exit_builtin_modules(void)
   cleanup_pike_type_table();
   cleanup_shared_string_table();
 
+  free_all_pike_list_node_blocks();
   free_dynamic_load();
   first_mapping=0;
   free_all_mapping_blocks();