The process is completed. - Are you sure?

Thank you for answering my previous questions. It really helps me to
move with Ruby.
Here is the next one:

So my long loops are completed. The task is one-threaded, so I am sure
that nothing MINE is still running. It is a time to work with amounts.

But there is a problem: Although I did not start any thread by myself,
but Ruby may for many reasons, some are obviious - there could be
exceptions, I have some rescue statements, etc.

So before working with amounts, I have to make sure, that all processes
caused by me are finished and there is nothing to take care about.

How to do it?

Please, help.
Thank you
Henry