If the program is in use in Windows or you have no permission to delete a file, you will see a dialogue box “Access is Denied” when deleting a file. If the file you want to delete is associated to a running process, you will not be able to delete the file successfully unless the associated processes has been killed or unloaded. There are files that are added by malware or spyware and if the processes of the malware are running, cleaning up the system will fail unless your anti-malware removal engine is smart enough to unload and terminate the offending processes files before proceeding to delete. Often, this is a failure in many anti-malware: to remove infection because the malware scanner failed to unlock, unload and terminate the process.
Booting to safe mode often help to delete locked malware files but that is possible only if the malicious processes will not run in safe mode.