This is a silly edge-case that doesn't make much sense, and I may be the only person who has clicked on the "Log Out" link while on the "Log Out" page, but I think the "cancel" link in this case should link to the home page.
Now, If you already keep a recent history of visited pages for the user in memory, perhaps the most recent page that wasn't the "Log Out" page should be used instead of the referer
header.
Or you could just link to a Google search for recursion. :-p