Only unregister client id when necessary