lib.sh: Fix stop condition in wait_for