You could do that with the following way
1. Define your own custom event class (inherit from %CSp.SessionEvents) then you may interact with the session creation/deletion:
2. In OnStartSession() callback in the event class, you may store the sessionId in your own global/table.
3. In OnEndSession() callback in the event class you may delete/kill your own data.
4. Pass the SessionId from the parrent window to the child (if you do not have it there already)
5. Have a timeout JS code to call the server using #server or #call every x sec. with a check of your own global/table for this SessionId.
If not exist - preform a "windowsClose" or a in-window message...
Here is more documentation abourt it :