Fixed releasing/removing a stale lock as an atomic operation to prevent race conditions inadvertent lock ownership.