title: Close Electron app on click event
body: <p>I have looked at the documentation for Electron regarding the 'frameless-window', but I just can't seem to make a button of my own work to close the application... </p>
  
  <p>Any help would be appreciated! Thanks!</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const electron = require('electron');
  const url = require('url');
  const path = require('path');
  
  const {app, BrowserWindow} = electron;
  let mainWindow;
  
  // Listen for app to be ready
  app.on('ready', function() {
    // create new window
    mainWindow = new BrowserWindow({width: 800, height: 600, frame: false});
    // Load html into window
    mainWindow.loadURL(url.format({
      pathname:path.join(__dirname,'main.html'),
      protocol: 'file:',
      slashes: true
    }));
    const closeApp = document.getElementById('closeApp');
  
    closeApp.addEventListener('click', () =&gt; {
      app.quit();
    });
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
    &lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
    &lt;meta http-equiv="X-UA-Compatible" content="ie=edge"&gt;
    &lt;title&gt;Electron "Hello World"&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;header&gt;
      &lt;p id="closeApp"&gt;close app&lt;/p&gt;
    &lt;/header&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>