Properly close pipe in run_get_stdout()