diff --git a/examples/main.c b/examples/main.c
index 39177560981c8d292ff4e69d871db7515645431c..9d3b910f8a1fcf24f78027666d62ef7be8ce064c 100644
--- a/examples/main.c
+++ b/examples/main.c
@@ -1058,6 +1058,7 @@ int main(int argc, char *argv[]) {
 
   /* Clean everything */
   if (with_verbose_timers) timers_close_file();
+  if (with_cosmology) cosmology_clean(&cosmo);
   engine_clean(&e);
   free(params);