title: Run a script before Command Prompt stops
body: <p>I have a Discord Bot that edits a message every second. So if the bot goes off, the message will display the last edit.</p>
  <p>I would like to, before closing the Node JS process (using Ctrl + C, closing the Command Prompt or any type of closing the process), edit the message to say something like: &quot;The bot is off&quot;.</p>
  <p>Example:</p>
  <pre><code>// something using discord.js
  bot.on(&quot;close&quot;, myFunction);
  
  // or in node, like in browser 'window.onbeforeunload'
  node.beforecloseprocess = myFunction;
  </code></pre>
  <p>If theres a way with discord.js, that would be cool and resolve my problem, but if there a way of using Node Js it self or something in the Command Prompt would be better for future projects aside discord.js.</p>