Query about "Display text in a window" function

Display Text in Window is an async operation - that is, it displays the text in a window and then the window is forgotten about and the macro moves on. Basically the same as Display Text Briefly which puts up a notification in Notification Center. So there is no way to close the window afterwards except by UI actions. So you could do something like finding the window on the screen and clicking there, but it’s pretty messy.

An alternative (fairly ugly I admit) would be to use the Custom HTML Prompt to display the text. Execute that asynchronously in another macro (using Executer Macro asynchronously) and so it would stay on the screen and the both macros would continue to run. When your primary macro finished, finish with the blunt instrument of Cancel All Macros which would cancel the second macro and remove the custom HTML prompt window. Not pretty, but it would work.

The only other alternative I can think of would be something that involved some other application displaying the text. Perhaps AppleScript? or you could open the text as a file in TextEdit and quit TextEdit when done.