examples/acquire_lock: Make termination more reliable