I want to close the Electron App by js.
"electron": "^13.1.7"
I read those questions carefully:
- Atom Electron - Close the window with javascript
 - How to close electron app via javascript?
 - Close Electron app on click event
 
But none of those work for me.
All the below tests are base on the offical electron-quick-start
According to the answers in questions above, I got these code:
index.html
  <body>
    <button id="close-app">
        close
    </button>
    <script src="./renderer.js"></script>
  </body>
main.js
const {BrowserWindow, remote} = require('electron')
...
app.whenReady().then(() => {
  ...
  app.on('activate', function () {
    ...
    document.getElementById("close-app").addEventListener("click", function (e) {
      remote.getCurrentWindow().close()
    })
  })
})
There is just no any effects or errors.
It seems like the code have never been run, I added a console.log('run') above the addEventListener and there is nothing been print in the console.
According to the document, I got these code:
(change nothing of the offical electron-quick-start but only preload.js and index.html)
index.html
as same as above
preload.js
const { app } = require('electron');
window.addEventListener('DOMContentLoaded', () => {
  document.getElementById("close-app").addEventListener("click", function (e) {
      app.quit();
  })
})
got Uncaught TypeError: Cannot read property 'quit' of undefined only

So, how can I close the Electron App by js?
Thanks a lot for anyone help!
