The problem here is at what stage the event is captured by your handler (or intercepted). The code in your question is being executed for events that bubble up to the document (events whose propagation has not been stopped by elements further down the document tree) during the final phase of propagation, not for all events that occur on document (what you are after).
In your case, you effectively want to stop the execution of the event for all descendants during the "capture" phase - look at Section 3.1 - (the first phase of event propagation).
Add true to the call to execute in the capture phase:
document.addEventListener("click", function (e) {
// ...
}, true);
You should also only need e.stopImmediatePropagation() in your handler.