methodtMailServiceShutdown.DrainChannels
procedure DrainChannels(const aFarewell: RawByteString; aReportMs: Cardinal; const aReport: tMailDrainReportEvent);
ORDINARY teardown of one component: has aFarewell sent on every registered session and the session closed, and waits until each has unregistered (the last thing the session's destructor does). The farewells and closes run on worker threads, never on the calling one, which only waits: on the main thread it runs CheckSynchronize while waiting, so a session callback that synchronizes with the main thread can still finish. After cMailDrainAbortMs the sessions still registered are closed abortively, so a peer that stopped reading cannot hold the wait. Only a session callback that never returns can: the wait has no bound, and every aReportMs it calls aReport with the milliseconds waited so far. Sessions registered while it runs are closed and waited for too.