I think you and @SteveC are under a misapprehension.
A qube wont shut down just because you “open and close an Xterm”, or
after a period of inactivity. app-shutdown-idle
will trigger if there is
no open window or no network activity (other options also available).
So if you are working in an app, open an Xterm in the same qube and
close it, nothing will happen.
If you are working in an app, and get distracted, nothing will happen.
If you are working in an app and close all windows in that qube then
it will trigger. But since you have closed all windows presumably you
have finished with the qube for the moment.
I advocate use of app-shutdown-idle
and the only cases of lost work
are where users close a document and fail to save their work. Your
scripting is not going to fix that.