You could maybe try to use:
app.Run(kTRUE); // return here using “any canvas main menu” -> “File” -> "Quit ROOT"
and then in your “infinite loop”, call “gSystem->ProcessEvents();” in regular intervals.
See also: Render the canvas while a script is still executing