Ensure the temporary directory is removed after a merge attempt.

Also generate the directory name using a random name to avoid name conflicts.