Remove orphaned temp files before attempting to remove directories (fixes #492)