Fix race condition in job dependency logic

If job involved in dependency completes and is purged the logic
used to test for circular dependencies can use the invalid pointer
and generate an invalid memory reference before the pointer is
cleared from the dependency list data structure.