pthreads invoking atexit()

I am trying to integrate a PRO*C mutlithreaded application. The application is invoking the atexit() function immediatly after executing the second sql function. I have set the thread attribute stack size to a larger amount. Does anyone have any other ideas on what would cause this.

atexit() is a function which registers another function (handler) to be invoked when your program is about to quit, and is not a function which is itself invoked during then. Also, this is a routine invoked only when there was a normal termination from your program, not otherwise (kill).
If you meant the function registered with atexit() is invoked after your second sql function, check to see if there was some SQL error in that function, which inturn was calling exit().
Also, post some relevant code, it would be helpful in analysing the situation better.