This is a followup to #56632. Tests that had to be changed to mock the C++ log handler more accurately need to be more careful about when that stream ends, as ending of that stream is used to detect crashes in the production system. Fixes #56796