abstract out job end check