I'm familiar with this problem for years, but to read here that it goes back over a decade unaddressed?! Wow! Here's the solution that's been working for us in shared hosting environments running linnux. It's pretty involved, technically, but we were in a situation where I couldn't be asking people to switch from Apple Mail to some other client.
via PHP on you hosting server run command line:
shell_exec("ps aux");
This will return a list of all your active server cinnections. It takes some effort to decipher, but included in it are things like what time the connection was initiated, the type of connection, and the all important PID number. Hosts can return this info in a variety of formats, and they can even evolve over time as your host upgrades their system, so you have to learn your hosts particular patterns.
You'll want to figure out which are the IMAP connections. Generally not hard to spot. Look for "imap".
Use grep if you need to limit the list, possible eg:
shell_exec("ps aux | grep imap");
(your needs may require a different grep)
The goal is to use this to generate a list of imap connections that are no longer active, which generally means imaps over a few seconds old (unless you're sending or receiving a large email or batches of emails and it's taking forever). So say any imap connection older than a minute or two. Get its PID and run the command line to kill it.
exec("kill -9 [PID]");
Algorithm:
Get all old IMAP connections
Kill them
Automate all of that and run on an interval, every minute.
I suspect a cron job is a good solution, but we use a web page so we can monitor the process in a browser. Wrap it hiwever you want
It resolved the issue for us for the last few years. Every so often the computer runing this code gets reset, and this routine is stopped, and sure as apples rot, our server laments too many connections and even blaclists our IP. So that's the hoops we jump through because Apple Mail can't kill old connections.
If you tell me that's crazy involved, you have my sympathy. We have yet to find a saner solution.