stop infinite loop when there are no jobs