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?
Asked
Active
Viewed 2,313 times
2
-
Did my solution work for you? – Joshua Aug 28 '18 at 17:41
-
I tried but it didn't work – Kshama Jain Aug 29 '18 at 07:05
-
When you quit your app do you press `Ctrl`+`C` in the terminal or do you call `app.quit()`? If its `Ctrl`+`C` then I don't think you can fix it but if it's `app.quit()` then my answer should work. – Joshua Aug 29 '18 at 08:37
-
okay I got yyour point .Thanks Mike.Your solution should work in app.quit case..I was trying with ctrl +c so it didnt. – Kshama Jain Aug 29 '18 at 12:36
-
No problem :), if my answer was helpful please [accept my answer](https://stackoverflow.com/help/someone-answers) – Joshua Aug 29 '18 at 13:56
1 Answers
4
Try destroying the tray icon before the app quits like this:
app.on('before-quit', function (evt) {
tray.destroy();
});

Joshua
- 5,032
- 2
- 29
- 45