Simplified, what I\'m doing is running this in the console:
window.onbeforeunload = function (e) { console.log(e); }
But in the console
Old question. But this simple solution worked better for me. Use
function(e) { console.dir(e); }