How to close electron app via javascript? How to close electron app via javascript? express express

How to close electron app via javascript?


you can use

const remote = require('electron').remotelet w = remote.getCurrentWindow()w.close()

to close your app.

if you are using jQuery

const remote = require('electron').remote$('#close-btn').on('click', e => {    remote.getCurrentWindow().close()})

if you are using Vue.js

<template>    <button @click="close"><i class="fa fa-cube" aria-hidden="true"></i>  Close application</button></template><script>    const remote = require('electron').remote    export default{        data(){            return {                w: remote.getCurrentWindow(),            }        },        methods: {            close() {                this.w.close()            }        }    }</script>


I use the line below to close the app.

window.close()


You can also use app.exit:

app.exit(0)

This seems to bypass any event listeners and force the whole app to exit immediately. (Be sure that is what you want though!)