Correct handling of explicit stream ends.