ws: Fix race crash when closing websockets