The question is not so much related to how to create a window, it is related to how to restore the underlying desktop screen when the window closes , which in this case means that the active cursor moves out of the window and back to the full screen desktop.
This code example shows one way a 'scrolling window' can be created. Please view the attached 'wintest2' file to see what this does.
The goal is to understand how to quit the window, probably with a 'hotkey' yet to be determined (esc, oa-q or something like that) such that the underlying text reveals itself after the window closes as one might expect in a modern computing environment. It seems that the way to do this is to save the contents of the screen before creating the window and restoring the full screen when the window closes. Any help is sincerely appreciated.