Fix possible endless loop when handling aborted jobs