Added shutdown of socket before exit