Fix lock release after record deletion