Make sure that stale lock is stolen only if it still free

Check that no other process has stolen it already by checking that the
stale value has not changed.
Also make sure that the new value set to lock is always different than
the old value.