What's happening is that tee "$logfile"
is being run asynchronously. When you use process substitution like that, the main script doesn't wait for the process to exit.
So the until
loop runs, the main script exits, the shell prints the prompt, and then tee
prints its output.
You can see this more easily with:
echo Something > >(sleep 5; cat)
You'll get a command prompt, and then 5 seconds later Something
will appear.
There was a thread about this behavior in comp.unix.shell a couple of years ago. See it here