For instance, when I click on the cross button to close Zoom, I still have to exit it in the system tray, which is really annoying. I guess I could change the settings in the specific program, but I don’t want to find this parameter in every program I use. Maybe there is a script that can stop some background programs, or I can change it in Windows settings?
Videos
There are some answers mentioned you can choose the tray icon and exit it, but if you want to close some program with one single shortcut combination, here is the solution:
You type
taskkill /f /im "theProcessNameGoesHere.exe"in notepad, replacetheProcessNameGoesHere.exein your actual program name, save it inkill_program.bat, create a shortcut of the saved batch file.Right click the the shortcut properties, in the Shortcut column, press the key that you perfer to close the program

Most programs that are in the system tray, have an EXIT right in the context menu.
So what you want to do is the following:
Press Win+b to make the focus on the system tray area.
Use the arrow keys to select the application that you want to close. Now hit space left mouse button action or menu (alternative shift+F10) right mouse button action or enter default action to open its menu and use the arrow keys to close the program or open it so you can close it from within the program itself.
I'm aware that not every keyboard has the menu button, so the alternative would be shift-f10.

Figure 1: Showing the menu key.
Hello all, I looked everywhere in the app but can't find the option, is there a way to 100% close the app when I close it ? I always have to also right click on it on the system tray and close it a second time, I like to keep my desktop as clean as possible :(
thanks in advance
I have a specific program that is running in the system tray icon ("ahk_exe QTranslate.exe"), I want it to be closed automatically from the system tray icon if it is running whenever I open another specific program ("ahk_exe phpstorm64.exe").
l've tried this, But this closes only the window of ("QTranslate") If it is exist, And It still running in the system tray :
loop{
WinWaitActive, ahk_exe phpstorm64.exe
if WinExist("ahk_exe QTranslate.exe")
{
WinKill, ahk_exe QTranslate.exe
}
}
- Is there any script to close the specified program from the system?
- Please help! I appreciate your time and effort. Thanks in advance.
Unfortunately, there's not much you can do to gracefully terminate an application that is not cooperating.
The suggested approach is to send the WM_CLOSE message to the window(s) of interest; this won't work here since the app chooses to hide itself as you describe. However, this is the only approach that Microsoft endorses.
The next step is to be a bit more heavy-handed and send the WM_QUIT message to a thread. This is a bit problematic because you have to find the thread in question using some form of process/thread enumeration and PInvoke PostThreadMessage to post WM_QUIT. However, MSDN seems to suggest that you should not do this (search for WM_QUIT). As a practical matter, it should work though.
If that doesn't work as well then Process.Kill is all you 're left with.
Update: The above is my own understanding, but there's also a Microsoft KB article on this same subject. It works with Win32 (not managed code), but the ideas can be adapted without much trouble.
The EventWaitHandle object in a BackgroundWorker solution provided here worked pretty good for me, and I think it's easier to code than using win API messages.
Basically you got a backgroundworker thread waiting for certain named event to happen with the myEventWaitHandle.WaitOne method.
Another application just creates the same named event and call myEventWaitHandle.Set() to trigger it. This cause the WaitOne() method in the background-worker to continue and therefore the RunWorkerCompleted to be triggered. At that point you can safely close your application.
Your main application:
private void evtBgWorker_DoWork(object sender, DoWorkEventArgs e) {
string evtName = "MyExitRequest" + Process.GetCurrentProcess().Id.ToString();
EventWaitHandle evt = new EventWaitHandle(false, EventResetMode.ManualReset, evtName);
evt.WaitOne(); // the worker stops here until the event is triggered
}
private void evtBgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
this.Close();
}
Your "graceful killer" application:
private void CloseMainApp()
{
Process[] processes = Process.GetProcessesByName("MyProcessName");
Process myprocess= null;
if (processes.Length > 0)
{
myprocess = processes[0];
string evtName = "MyExitRequest" + myprocess.Id; // the same event name
EventWaitHandle evt = new EventWaitHandle(false, EventResetMode.ManualReset, evtName);
evt.Set(); // triggers the event at the main app
if (!myprocess.WaitForExit(10000)) // waits until the process ends gracefuly
{
// if don't...
myprocess.Kill();
}
}
}