To add to that - the Agent should also never make changes to the registry that could affect other agents. The call to `registry.StopJob` needs to be changed to limit modifications to the local agent, which then could benefit from holding the state lock.