Fix killing of connections from the main thread.