back in the XP days, I used a software called “Unlocker” just for this problem. It probably still exists, I don’t know, because since Windows 7, the easiest way to find out what process locks a file is to open Resource Monitor (Start search: resmon) and the bottom list on the CPU tab you can search the file name and you will find the process.

So yeah, Resource Monitor is a useful tool on Windows.

There’s a collection of free little utilities called Microsoft PowerToys, including the file unlocker thing. Why would they not include these into base kit Windows is beyond me.
GitHub - microsoft/PowerToys: Microsoft PowerToys is a collection of utilities that help you customize Windows and streamline everyday tasks

Microsoft PowerToys is a collection of utilities that help you customize Windows and streamline everyday tasks - microsoft/PowerToys

GitHub
Because they want to include things with ads now.