Enter Unlocker, a tiny application, completely free, which will fix all your problems and be useful whenever you're stuck with this problem. It adds itself to Explorer's context menu and places a small icon in the taskbar. Whenever you encounter such an error, it will automatically grab it and ask you if you want to "unlock" the file. This will destroy all the file locks placed by any application which is currently using the file, allowing you to modify/delete it as per your needs.

click to enlarge
It comes as a tiny 255-KB application that will be installed instantly. Once done, just right click on the offending file and click on Unlocker. It will instantly list all applications that are currently locking the file. To unlock the file, just click on "Unlock All" to kill all open handles for that file. Alternatively, you can instead kill the process that's hogging the file or select a specific application from the list and destroy all the handles created by that application.