Merge "fix a possible deadlock when removing a layer and destroying a client"