That wasn't the exact problem, but it made me think. I am reading scanned images from a file server and they are automatically cached on the local disk. The images for the last retrieval were still displayed on the screen, so they were in use and the cache folder(s) containing them could not be deleted.

So, I just cleared the image from the screen and all seems to be working fine.

Thanks for your help.