Improve termination detection in utilities.