<html> <body> <script type="text/javascript" charset="utf-8"> window.addEventListener('unload', function (e) { require('fs').writeFileSync(__dirname + '/unload', 'unload'); }, false); </script> </body> </html>