fix unlock retry logic so we actually unlock (fix #1295)