lib: Fix a shutdown crash with "clustering = yes"