Looks like I've found a good (but maybe resource-consuming) way to calculate "right moment to stop" for harvesters with loadingDelay>0.
On every update, amount of harvested crops is saved in element of spec_combine.loadingDelaySlots[i], which function like some kind of ring buffer: new element added to buffer storage, oldest valid element - delivered to tank.
So, total amount of undelivered crops = sum of spec_combine.loadingDelaySlots[i].fillLevelDelta for all valid slots.
Slot is valid if spec_combine.loadingDelaySlots[i].valid == true.
And if this sum is lager than free space in tank - it's time to stop harvesting.
This buffer have total of loadingDelay / 1000 * 60 + 1 elements (file Combine.lua from game sources, line 713).