Fixes issues with deleting files and cleanup on windows.

I'm guessing there's no cheaper way to determine if a directory is non-empty?