Fix removal of dead sockets from the stash

We were modifying the stash array while iterating over it, causing sockets that were still connected to miss messages.

This was a bit of a head scratcher! I thought about using `reject!` but that would have meant calling `remove_socket` in such a way that it wouldn't actually do the removal. No test case because this seems like a tricky one to test. I'm short on time and you could probably do it much quicker.