Often seen as a collection point for all the miscellaneous functionality that seems to fit nowhere else, the stdlib contains many interesting features for a variety of applications.
You previously used the return keyword in the main function to leave the program itself; however, stdlib also offers some additional exit handling that extends this behavior. The first, atexit, is defined as:
atexit ( <function> ) execute function on exit
This function allows you to specify up to 32 functions (in separate calls to atexit) to execute when the program terminates normally. These functions cannot accept any parameters and will be executed in the reverse order to which they were set up by repeated calls to the atexit function. ...