How does Wechat web developer monitor and close web pages?

how do I monitor this behavior before closing Wechat"s web page? Similar to JD.com Shopping prompts "whether to quit" before quitting the page


window.onbeforeunload=function(e){     
var e = window.event||e;  
e.returnValue=("");
} 
Menu