This script solves a Windows bug where Task Manager (taskmgr.exe) moves to the background and consumes memory after you close it. The script automatically terminates Task Manager when it's running in the background AND you're not actively using your system.
In recent Windows versions, when you close Task Manager, it doesn't fully exit—instead, it moves to the background and keeps consuming memory. Each time you close it, it moves to the background again, eating up more RAM.
Affected Versions:
- Windows 11 24H2
- Windows 11 25H2
- Windows 11 Insider Preview (Build 26200+)
- Other recent builds may also be affected
This is a widespread issue across recent Windows updates/KB patches.
This script monitors your system and automatically cleans up Task Manager only when:
- Task Manager is NOT actively in use (not in the foreground)
- You haven't used your keyboard/mouse for 30+ seconds (system is idle)
This ensures Task Manager stays responsive while you're using it, but gets terminated when it's just lingering in the background.
Option A - Download just the script:
- Click on
kill_taskmgr.ps1file above - Click the "Download raw file" button (or right-click → Save as)
- Save it to your Desktop
Option B - Download the entire project as ZIP (Recommended):
- Click the green "<> Code" button at the top
- Click "Download ZIP"
- Extract the ZIP file to your Desktop
- You'll have both
kill_taskmgr.ps1andREADME.md
Open PowerShell and run:
powershell -ExecutionPolicy Bypass -File "$env:USERPROFILE\Desktop\kill_taskmgr.ps1"Or simply navigate to Desktop in PowerShell and run:
powershell -ExecutionPolicy Bypass -File ".\kill_taskmgr.ps1"The terminal window must stay open while you want the script running. When you close the terminal, the script stops.
- Open Task Manager (Ctrl+Shift+Esc)
- Use it normally
- Close it
- After 30 seconds of system idle time, it will be automatically terminated
When running, the script will display messages like:
Task Manager (PID: XXXX) is active in foreground- while you're using itTask Manager (PID: XXXX) in background- when it's closed but still in memoryKilling Task Manager- when it gets terminated after idle period
The script uses Windows API calls to:
- Detect the foreground window - Knows when Task Manager is actively in use
- Monitor user activity - Tracks keyboard/mouse input to detect idle time
- Process management - Terminates Task Manager only when both conditions are met (background + idle)
- ✅ No personal information is revealed in this script
- ✅ Safe to share - completely generic, works on any Windows system
- ✅ Reversible - just close the terminal to stop it
- ✅ No admin rights needed - regular user can run it
- ✅ Open source - MIT License, free for everyone to use
- ✅ Examine the code - review the script before running if you want
- ⏳ Temporary fix - Wait for Microsoft to release an official Windows patch
- Windows 11 (24H2, 25H2, or later)
- PowerShell 5.0 or higher (comes with Windows)
- No administrator privileges required
You can safely share this repository or download link with others:
- GitHub URL: https://github.com/1LUC1D4710N/kill-taskmgr-script
- Download: Click the green
<> Codebutton and selectDownload ZIP - No personal information is exposed
- Completely safe and open source
- MIT Licensed - free for anyone to use
⏳ Temporary Workaround: This is a temporary solution while waiting for an official Windows patch from Microsoft.
Once Microsoft releases a Windows Update that fixes the Task Manager background memory leak issue:
- Close the script - Stop the PowerShell terminal running the script
- Delete the files - You can safely delete the script
- Update Windows - Install the official Windows patch
- Test Task Manager - Verify that Task Manager no longer lingers in the background
You can monitor Windows updates on the Microsoft Windows Release Health Dashboard to see when this issue is fixed.
If you want a simpler solution, you can use Command Prompt to kill all running Task Manager instances. Here's the command:
taskkill /im taskmgr.exe /fSimply open Command Prompt or PowerShell and run the command above. This will immediately terminate all Task Manager processes. However, this is a one-time fix - if Task Manager lingers again, you'll need to run the command again. Use the script above for an automatic, continuous solution.
This script demonstrates:
- PowerShell scripting and automation
- Windows API P/Invoke calls in PowerShell
- Process monitoring and management
- System idle time detection
- Error handling and logging
- Windows command-line process management (
taskkillcommand)
MIT License - Free for everyone to use, modify, and distribute. See LICENSE file for details.
If you have improvements or find issues, feel free to open an issue or submit a pull request.