Fixed a locking race condition

We found a race condition where two workers would occasionally both complete the same job. The first worker to finish the job finishes successfully, but the second worker would try to delete the job (thinking it finished successfully) and that worker process would crash as a result.

This pull request addresses this race condition.