This is a context manager to cleanup your environment. Your claenup code will be called even if the program is stopped by Ctrl-C or kill command.
Create atomic loop iterations (let the current iteration finish even when interrupted)