I made a snapshot of what's happening when I Shut Down (see below) and guess what, Mail is Deleting trash of all of my mailboxes at once at that very moment, however the setting to do permanent deletion is set ot Never on my accounts. This activity might be hanging and causing the Shut Down to be cancelled, but for some reason I could not reproduce this error since I reported it. Will keep testing and see if it re-occurs. Until then, if you have any ideas or suggestions, they are always welcome.
This solved it for me. (I have no idea why it works)
- From the Apple menu bar, select "Mail" then "Preferences"
- Select "Accounts"
- You should see each of your email accounts that you use Mail for listed individually and will need to take the remaining steps for each one listed.
- Select your email account in the left window, and notice the last item on the screen in the right window is the TLS Certificate
- Click on the selector next to "TLS Certificate:"
- Choose the "com.apple.idms.appleid.prd.xxxx" listing instead of "None"
- Quit Mail
After doing the above, the next time I had Mail open and selected "Shut Down..." while it was opened, it shut down without the shutdown being cancelled by Mail. As this has worked now three days in a row, I'm calling it solved.
I hope if works for you as well
I guess Apple only allows a limited time to edit your posts before you have to start a new one or reply to yourself. Oh well, stupid is as stupid does.
As expected, the behaviour returned. The problem started to return gradually. First, there would be a delay until quit. Now, Mail refuses to quit at all. I won't try force quitting yet.
There is no activity in the activity viewer. Connection doctor declares that all is well and the Force Quit window finds Mail responsive.
Going to Activity Monitor shows three processes, one duplicated. They are:
Mail Web Content (times 2)
Mail and com.apple.MailServiceAgent are the two processes that were hard to quit and needed a kill signal. (Yes, I could have Force Quit, Comm-Opt.-ESC and that may have worked but it would have hidden from me which process was failing.)
So, I relaunch Mail and only two processes show up. Mail & Mail Web Content. And Mail is working like a charm and quits, albeit a bit slowly. So, I launch again and watch the activity viewer. After a while, a duplicate of the Mail Web Content process shows up in the Activity Monitor (not to be confused with Mail's activity viewer.) running as a seperate, sequentially numbered process.
Then I try to send a message, that's when the com.apple.MailServiceAgent shows up. That works. So, I try quitting again (exactly when no activity is showing.) and the delete activities appear and slow things down but eventually, Mail quits.
There are two accounts, in my case, an iCloud account and a third Party Domain. It's the iCloud account that seems to be slowing things down when you watch the activity viewer. I can disable the third party account and see the same problems.
com.apple.MailServiceAgent stays active after Mail quits.
So, that's what I know. It's working again, albeit slow to quit. I bet if I leave the MBP running for a day or two and sleep it each night, this problem will have resurfaced.
The sad part is that I have diligently looked everywhere to see what's going on and while I can point to the two processes that needed killing, I don't have a solution and I don't know why they only need to be killed sometimes.