Fix bug in client detach