Actually scratch my other answer.
I think the real reason for the early termination was that I was using an async function to do a screenshot, but forgot the await on the call.
So the parent function was closing the browser before the promise resolved.