Only unregister client id when necessary
Merge bug25744
stable to default