How about you check - before unsetting the session - if there are, let's say, five minutes left?
if($_GET['endsession'] < time() + 5*60) {
//alert the user
}
if($_GET['endsession']) {
//your code to unset the session
}
Assuming $_GET['endsession']
contains a timestamp. If this is not the case you may as well transform it or whatsoever, but I think the general idea is clear.