Move exitedException capture above other logic, to ensure it sets.