Fixing a bug that would result in accidental closures of sockets