Fix termination checking