Correctly handle unregistration.