Fix possible use-after-free on client disconnect