Unfortunately, no. Dynare will try to delete that folder itself, but sometimes this operation is blocked. On my machine that happens particularly if the folder is synchronized by a cloud drive.
Thank you for your response. Let me add. After the rmdir, add the line clear M_;
To avoid the warning “The value of local variables may have been changed to match the globals.”
It doesn’t look like. Before the eval, I create the local variable M_.fname = 'modfile'. Dynare then creates a file driver.m in which M_ is created again as global. At this point, it generated the warning. When I added the clear M_ before running dynare, the warning disappeared.