That sorted it. I did not thing that just linking to the logout page would actually close the connection, but it does.
<a href="logout.php">Log out</a>
if you want that link to be a button image:
<a href="logout.php"><img src="logout.jpg" /></a>