There were two problems: - Windows refuses to remove a file that is in use. Solution, close the repo before cleaning the temporary directory. - Windows refuses to remove a read-only file. Solution, change mode to writable.