This prevents leaving all sockets open until the script exits. It would be better to reuse the existing socket when it's already connected to the right place, but this is easier for now.