Web browsers have a feature for pinning tabs. A pinned tab doesn’t have a close button that can be clicked accidentally and it’s an easy way to prevent accidentally closing something important. Unfortunately, something like this isn’t available on an OS level to prevent you from accidentally closing an app.
If you want to keep yourself from accidentally closing a File Explorer window, you need an app called NoClose. It’s meant to work for other apps and isn’t just limited to File Explorer however, there’s no definitive list of apps that it will work with. We do know for a fact that it works flawlessly for File Explorer.
Prevent accidental close File Explorer
Download and run NoClose. The app works by disabling the close button for a window. Open File Explorer and tap the Ctrl+1 keyboard shortcut to disable the close button. Tap the same keyboard shortcut to enable it again. Use the number one key at the top of the alphabet keys. The shortcut won’t work with the number pad.
NoClose also supports rules for disabling the close button on certain app windows. You can apply rules with the Ctrl+2 keyboard shortcut however, they must first be configured.
To configure rules, right-click the app’s icon in the system tray and select Settings from the context menu. Go to the Rules tab. The syntax given is pretty easy to follow but, you will likely get stuck where it comes to entering the Class for an app. To find the correct class name for an app, open it and use the Ctrl+1 keyboard shortcut to disable its close button. The Rules tab will list its Class.
The rules can be used to automatically hide the close button for a particular app window e.g., when you have a specific Notepad file open.
NoClose works for File Explorer and Notepad. It doesn’t work for UWP apps, nor does it work for Chrome. It appears to be a hit and miss with desktop apps. It will work for VLC player and Paint, but not for Firefox.
As for closing a window that NoClose has disabled the close button for, you cannot close it by right-clicking the app’s icon in the taskbar however, you can close it by clicking the close button on the app preview that appears when hover the mouse cursor over its icon on the taskbar. The app is simple and as such, it doesn’t have that many features but can be a reasonably good way to prevent yourself from accidentally closing an app window.