Clean output stream closing