fix to handle a different case of closing streams