Disconnect socket before exit.