If exit() is too abrupt, you can always use setjmp() and longjmp() to set up a non-local jump to an error handler.
http://www.on-time.com/ddj0011.htm
I'm almost tempted to make an analogy with scheme's (call-with-current-continuation) here, but I think that might be pushing it.