# Housekeeping in the frame's Kill embed does not run when a terminal server session is cut off

**URL:** <https://forums.softvelocity.com/t/housekeeping-in-the-frames-kill-embed-does-not-run-when-a-terminal-server-session-is-cut-off/1505>\
**Category:** Knowledge Base\
**Tags:** templates, unverified\
**Created:** [November 9, 2026, 2:12am UTC](https://forums.softvelocity.com/t/housekeeping-in-the-frames-kill-embed-does-not-run-when-a-terminal-server-session-is-cut-off/1505 "2026-11-09T02:12:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rzaunere](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rzaunere](https://forums.softvelocity.com/u/rzaunere)\
**Post date:** [November 9, 2026, 2:12am UTC](https://forums.softvelocity.com/t/housekeeping-in-the-frames-kill-embed-does-not-run-when-a-terminal-server-session-is-cut-off/1505/1 "2026-11-09T02:12:11Z")

</div>

**Applies to:** posted in the Clarion 10 group; an app run through a terminal server product (tsPlus) on Windows Server.

**Problem**

Code in the main frame's Kill procedure embed, before the file close methods, updates user fields in a user table. It runs when the user exits. If the connection times out, the user is forced off, or the browser tab is closed, it does not run. This also affects counting concurrent users against the license.

**Solution**

1. Accept that the program is killed and gets no chance to run code; nothing in an embed can catch it.
2. Make the program know the session is about to time out. One poster ran a batch file from the Task Scheduler every minute that writes `query.exe user > Users.txt`, which includes each user's idle time.
3. In the program's Timer event, read the idle time of its own session, warn the user and terminate before the server does. The original poster planned the same, using an idle-time function in a third-party file tool library.
4. The Event:Shutdown embed was suggested, but it is probably called before Kill, so the result may be the same.

**Caveats**

- A closed browser may leave the session alive, even with several copies of the program running, depending on the terminal server settings.
- A closed browser or other disconnects need more craft than the idle timer alone.

**Today (2026)**

Likely unchanged, as it depends on the server, not on Clarion; not re-tested.

**Sources:** Greg B. (Jun 2019, the question), Geoff, Sean H., Bob C. (Jun 2019) in sv.clarion.clarion10.
