atexit
Atexit is a mechanism used in several programming environments to register callbacks that will be invoked automatically when a program terminates normally. The callbacks are used to perform cleanup tasks such as releasing resources, flushing I/O buffers, or saving state. Although implemented differently across languages, the core idea is to run user-defined cleanup code during shutdown rather than at arbitrary points during execution.
In the C standard library, atexit is declared as int atexit(void (*func)(void)); It registers func to be
In Python, the atexit module provides atexit.register(func, *args, **kwargs) to add callbacks that will run when