Only close the output if it's not stdout