Use pid for temporary folders, fixes #638.