diff --git a/master/master.c b/master/master.c
index 5fc0d72dc2e973db9f728599329171004d033c5d..6563fd036e60daf91e1f10af22374676ba2dd1e7 100644
--- a/master/master.c
+++ b/master/master.c
@@ -229,9 +229,9 @@ void ec_master_clear(
 #ifdef EC_EOE
     ec_master_clear_eoe_handlers(master);
 #endif
+    ec_master_clear_domains(master);
     ec_master_destroy_slave_configs(master);
     ec_master_clear_slaves(master);
-    ec_master_clear_domains(master);
     ec_fsm_master_clear(&master->fsm);
     ec_datagram_clear(&master->fsm_datagram);
     ec_device_clear(&master->backup_device);