You could accomplish this using Javascript and frames.
What you would do is have an intial loading page that simply loads a frame that takes up the entire window, and loads your site's index in the frame. When the window is closed, an 'onunload' event is triggered and will open a page that logs the user out.
If you know any Javascript, you can tweak this script to your liking. Note that on the loading page, you can NOT insert this source inside a <body> tag; it must be either in a <head> tag, or in no tag at all (well, other than <html> of course).
This would be the contents of the loading page:
<script language="JavaScript" for="window" event="onunload">
window.open('http://mysite.com/php/logout.php');
</script>
<frameset border=0 rows="100%,*" noresize>
<frame marginwidth=0 marginheight=0 frameborder=0 framespacing=0 name="TOPFRAME" src="http://mysite.com/php/index.php"
noresize>
</frameset>