I have not looked in detail at the program. You could see whether there are other options to disable the type-ahead. Others here may have some additional ideas, but you have a situation where that program is doing the acting based on your script's output. You would either need to alter the program or have your script take action upon the program's action. For some programs, sending a Backspace, Esc, or other key can work, but I have not tested whether this would work here.