Fixed issue where temporary directory could not be deleted