[utils] fix tempdir ctxmgr to ensure we go back to a fine cwd (closes #3652139) [applied]