Fixing lock release in reparenting on error.