Is this the only way to terminate?

The really issue is: how to know when done processing all the items?

I have finally found the post that I asked before and answer by you, almost same question as this. but I still haven’t found a good way to solve this.