Fix closeoutput problem