Check if a pageID is actually active

No, there's a timeout. Browsers are not required to notify a server of tab closures, and generally don't. I think you are going to have missed notifications if you have to target only one page.