Use atexit() so can exit on fatal errors