Use exit instead of std::exit

Since we include stdlib.h (not cstdlib), std::exit is not defined in OSX.
So we use exit function instead of std::exit.