Fix an infinite loop in the scheduler.