How to Fix Windows Error: "An operation is being attempted on a shell that is being closed"
Description of the Error
This error occurs when an application or a background service tries to interact with a Windows shell interface (such as File Explorer or the Command Prompt environment) that is currently in the process of shutting down or being closed by another system thread. In multi-threaded environments, conflict arises when one thread commands the shell window to close while another thread simultaneously attempts to execute a command, read data, or modify a UI element within that same shell instance. It commonly happens during system shutdowns, application crashes, automated scripting, or due to corrupted system files interfering with standard process workflows.
Step-by-Step Fixes
Step 1: Restart Windows Explorer
Often, the shell state becomes glitched, and a simple restart of the user interface host resolves the thread conflict.
- Press
Ctrl + Shift + Escon your keyboard to open the Task Manager. - Click on More details at the bottom if you are in the compact view.
- Scroll down the Processes tab and look for Windows Explorer.
- Right-click on Windows Explorer and select Restart.
- Your taskbar and desktop icons will disappear for a brief second and then reappear.
Step 2: Run System File Checker (SFC) and DISM
Corrupted system files can cause threads to hang or close unexpectedly. These built-in utilities will repair damaged Windows components.
- Press the
Windows Key, typecmd, and select Run as administrator. - Type the following command and press
Enter:DISM.exe /Online /Cleanup-image /Restorehealth - Wait for the process to complete (this may take several minutes).
- Type the next command and press
Enter:sfc /scannow - Once the verification reaches 100%, restart your computer.
Step 3: Perform a Clean Boot
Third-party background applications or conflicting services might be closing shell processes unexpectedly. A clean boot helps isolate the problematic software.
- Press
Windows Key + R, typemsconfig, and clickOK. - Go to the Services tab.
- Check the box that says Hide all Microsoft services.
- Click the Disable all button.
- Move to the Startup tab and click Open Task Manager.
- Disable every startup item by right-clicking each one and selecting Disable.
- Close Task Manager, click Apply and OK in the System Configuration window, then restart your PC.
Step 4: Clear the File Explorer History
Cached data inside the shell environment can sometimes trigger indexing or memory management thread lockups.
- Press
Windows Key + R, typecontrol folders, and pressEnterto open File Explorer Options. - Under the General tab, look for the Privacy section at the bottom.
- Click the Clear button next to Clear File Explorer history.
- Click Apply and then OK.
There may be some errors. Learn Microsoft