Search code examples
electrondestroytrayicon

tray icon doesn't close immediately on app.quit in electron


I am using electron tray in my application but when I quit the app ,the tray doesn't close immediately.Instead on hover, it closes immediately .Is there any solution that I can use to avoid this?


Solution

  • Try destroying the tray icon before the app quits like this:

    app.on('before-quit', function (evt) {
        tray.destroy();
    });
    

    tray.destroy() Docs.

    before-quit Event docs.