title: How to close electron app via javascript?
body: <p>I am running an express app via electron.</p>
  
  <p>Below is the main.js</p>
  
  <pre><code>   const electron = require("electron"),
            app = electron.app,
            BrowserWindow = electron.BrowserWindow;
  
      let mainWindow;
  
      function createWindow () {
        mainWindow = new BrowserWindow({
            width: 1200,
          height: 800,
          frame: false,
          kiosk: true
        });
        mainWindow.loadURL(`file://${__dirname}/index.html`)
       mainWindow.webContents.openDevTools();
  
        mainWindow.on("closed", function () {
          mainWindow = null;
        })
      }
  
      app.on("ready", createWindow);
      app.on("browser-window-created",function(e,window) {
        window.setMenu(null);
      });
  
      app.on("window-all-closed", function () {
        if (process.platform !== "darwin") {
          app.quit();
        }
      });
  
  
  
      app.on("activate", function () {
        if (mainWindow === null) {
          createWindow();
        }
      });
  </code></pre>
  
  <p>and below is a button in the view that upon click i would like it to close the app </p>
  
  <pre><code>&lt;button id="close-btn"&gt;&lt;i class="fa fa-cube" aria-hidden="true"&gt;&lt;/i&gt;&amp;nbsp; Close application&lt;/button&gt;
  </code></pre>
  
  <p>Essentially I want to activate this part of the code once the button has been clicked</p>
  
  <pre><code>  app.on("window-all-closed", function () {
            if (process.platform !== "darwin") {
              app.quit();
            }
          });
  </code></pre>