Have you ever been stuck in a
string of pop-up ads where you close one and it opens another? It is possible.
The only thing I can think of is to use javascript to detect a window close in the pages that are only accessible to logged-in users. This detection would trigger a pop-up window to open. The pop-up's request will clean up the session on the server and send back a page telling the user that they should play nice and log out next time (even though it's taken care of).
The drawbacks to this approach is that a browser with javascript turned off or with a pop-up blocker might prevent it from working.