Personally I often sign in anonymously because I have a nasty habit of opening topics in tabs and forgetting to close them for a while, and I'd rather people see an anonymous user reading their topic for an hour (i.e. having it open in a forgotten tab for an hour) than have them see my username.
AFAIK, you will only be listed in the most recently viewed page, and will automatically appear as offline after ~20 minutes of inactivity.
The server can't tell the difference between you sitting on a webpage and closing it. It only can see new requests, not the absence of them. And since pages don't auto-refresh for new content, I don't think there is any AJAX going on to test if a user truly is still viewing a page.