Fix a race condition that could cause the wrong GCM ID to be unregistered during upgrade