Fixing unregistration during shutdown