#include <stdlib.h>
int atexit(void (*func) (void));
atexit() lets you install a function that is to be executed just before the normal termination of the program. You can register at most 32 functions with atexit(). The first function registered is the last function called; likewise the last function registered is the first function called.
atexit() returns 0 if it registered the function, otherwise it returns a non-zero value.