Added detection of halting.