diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 169426c4ce8d4606abd88fbb51d55cd9f65716fb..e1d79c83a2d7790325f95c9df61f63098b625e46 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -4743,6 +4743,11 @@ static int unload_module(void)
 	io_context_destroy(io);
 	sched_context_destroy(sched);
 
+	mark_mappings();
+	prune_mappings();
+	mark_peers();
+	prune_peers();
+
 	return 0;
 }