A process can terminate either abnormally or normally. Abnormal termination occurs on delivery of certain signals, some of which also cause the process to produce a core dump file.
Normal termination is accomplished by calling _exit() or, more usually, exit(), which is layered on top of _exit(). Both _exit() and exit() take an integer argument whose least significant 8 bits define the termination status of the process. By convention, a status of 0 is used to indicate successful termination, and a nonzero status indicates unsuccessful termination.
As part of both normal and abnormal process termination, the kernel performs various cleanup steps. Terminating a process normally by calling exit() additionally causes exit handlers registered using atexit() and on_exit() to be called (in reverse order of registration), and causes stdio buffers to be flushed.