It doesn't necessarily need to happen simultaneously though. Like I said, I can have a dozen bots all at very different stages in the processing of an item type (such as running threshers with cereal) and all but one of the bots will have this glitch. It seems to be something to do with how they are reacting to the storage unit once it is full. If I had to guess, it was a boundary condition you are using with the test for a full storage container, where you are currently only looking at if the bot put in the last item.
Those logic bugs are the kind that tear your hair out, so I completely understand and am sympathetic with why it exists.
I even get a sort of weird situation where due to the fact it isn't completely simultaneous that some arbitrary number of bots won't necessarily glitch out. What I think is happening there is that due to the heavy demand of that item to and from multiple storage containers, that the bots who glitch out slow down production thus allowing the other bots who are consuming that item (like making bread) to catch up and make space available to some of these bots who aren't glitching to put items into storage. If for some reason the consumption of items from the whole production chain is halted (as is the case sometimes when setting up a completely unrelated production chain), I have this happen to all but one of the bots without fail. I can easily reproduce this situation every time it fits this criteria.