Hi Eric,
A couple of questions for you.. Are you the systems administrator on your Citrix server?
Rather than spend the time trying to work this out, why not just set the properties of the Citrix connection so that when a client disconnects their session (either via the X or by shutting down their PC), it is automatically disconnected, or disconnected after about 15 minutes.
I've found that the above works very well without having to code anything.
I'm sure you have your reasons, but just a thought...