You might use exit() function; it might be considered bad programming if used in the wrong place by some people.
I did not really look at your code.

exit - C++ Reference

Note: Exit exists in...