this is a bit tricky, I've messed with it some time ago, but never found
THE solution
maybe u could use Javascript's onUnload="" which must be written
in the body-tag, you could call a form in the called function, which
performs the required actions
only it would be called each time, the user hits a link, even on your site
probably better is some kind of timeout, for example a function
is called every time a user enters the site.
it deletes all sessions which are older than ~5 minutes, else renew
its timestamp (with touch())