It's not a problem with exit. It's a matter of the stream not flushing which means its still in pending. Using std::flush instead of std::endl will give a similar and proper result.
Well, the problem is not with the code you posted, but somewhere else (invalid memory accesses or whatnot). Then again, hard to tell without even knowing what _lname is.