Making a timer-using Raspi console app stoppable?

I use a xojo timer in a Raspi console app and want to get a keyboard input to stop the loop.
I found this thread https://forum.xojo.com/7379-console-app-basics-quitting-possible/0#p51623 and set up a similar method, but Result always stays at length 0. Any ideas what I might be making wrong?

result ="" do app.DoEvents result = result + stdin.ReadAll loop until result.Right(1) = "x"