Fix a bug in tmp dir removal