Apps Add Close All Apps context menu in Windows 11


  • Staff
Close_banner.png

This tutorial will show you how to add "Close All Apps" to the desktop context menu for all users in Windows 10 and Windows 11.

Sometimes you may need or want to quickly close all open apps at once instead of one at a time without shutting down or restarting the computer.


While you must be signed in as an administrator to add or remove the "Close All Apps" context menu, all users can use the context menu if added.


The Close All Apps context menu will forcefully close all open apps except File Explorer and Registry Editor, so be sure to save anything open in an app before using the context menu.



EXAMPLE: "Close All Apps" context menu

In Windows 11, you will need to click/tap on Show more options first by default, then click/tap on Close All Apps.


Show_more_options.png
Close_All_Apps_context_menu.png



Here's How:

1 Do step 2 (add) or step 3 (remove) below for what you would like to do.

2 Add "Close All Apps" to Desktop Context Menu

A) Click/tap on the Download button below to download the file below, and go to step 4 below.​

Add_Close_all_apps_at_once_context_menu.reg


(Contents of .reg file)
Code:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\CloseAllApps]
"MUIVerb"="Close All Apps"
"icon"="imageres.dll,-5102"
"Position"="Bottom"

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\CloseAllApps\command]
@="PowerShell -Command \"Get-Process |? {$_.MainWindowTitle -ne \\\"\\\" -and $_.Id -ne $PID -and $_.ProcessName -ne \\\"explorer\\\"} | Stop-Process -Force\""

3 Remove "Close All Apps" from Desktop Context Menu

This is the default setting.


A) Click/tap on the Download button below to download the file below, and go to step 4 below.​

Remove_Close_all_apps_at_once_context_menu.reg


(Contents of .reg file)
Code:
Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\DesktopBackground\Shell\CloseAllApps]

4 Save the .reg file to your desktop.

5 Double click/tap on the downloaded .reg file to merge it.

6 When prompted, click/tap on Run, Yes (UAC), Yes, and OK to approve the merge.

7 You can now delete the downloaded .reg file if you like.


That's it,
Shawn Brink


 

Attachments

  • Close.png
    Close.png
    1.2 KB · Views: 11
  • Add_Close_all_apps_at_once_context_menu.reg
    1.1 KB · Views: 32
  • Remove_Close_all_apps_at_once_context_menu.reg
    512 bytes · Views: 22
Last edited:
Brink,

This included PowerShell script, which I've seen several versions posted, falls short of closing ALL desktop apps. What's missing?
- doesn't close any File Explorer windows​
- can't find UWP apps​
- can't close any elevated apps like Administrator CMD or PowerShell​

1. The code for closing open Explorer windows, without restarting the desktop, is known.
Code:
(New-Object -ComObject Shell.Application).Windows() | %{$_.Quit()}

2. Next part is fixing the faulty logic everyone uses to determine a list of running desktop apps. The correct answer is to find processes running under your current User Session (SessionId), and have a non-zero MainWindowHandle. Why is SessionId important? You might be on a system with Remote Desktop sessions, and don't want to kill someone else's apps.

Don't forget to skip 'explorer' process, since we don't want to restart the Desktop.
Code:
Get-Process |? {$_.SI -eq (Get-Process -PID $PID).SI -and $_.MainWindowHandle -ne 0 -and $_.Name -ne 'explorer'} | Stop-Process -Force

3. You can't terminate any elevated apps like Administrator CMD or PowerShell, or regedit. The answer is to use an elevated Scheduled Task which grants us privileges without triggering UAC.

4. Finally some users will object to the flashing PS window pop-up. Time to use the "invisible" VBScript trick, called from the elevated task.

INSTRUCTIONS

Download and extract the ZIP file to whatever folder you will leave the CloseAllApps.vbs script.
As Administrator, run the install.bat or uninstall.bat to add or remove the "Close All Apps" context menu.

For W11 23H2 users, you will continue to see a brief flash from PowerShell.
Apparently when they updated Terminal to be the default PS console host, it doesn't bother obeying the invisible trick. :nope:
 

Attachments

  • CloseAllApps.zip
    1.1 KB · Views: 12
Last edited:

My Computer

System One

  • OS
    Windows 7
Back
Top Bottom