Ensure conditional stream ends properly