Changed way output streams are closed