J-M-L and Delta_G are spot on about just using an if statement, but I have one small thing to add. If in the future you had a bigger function and want to call another function and terminate the current function look into 'return'.
void function() {
...some function code...
if (whatever == true) {
otherFunction(); //calls otherFunction, once otherFunction is complete the program continues here
return *note*; //possibly return some data, and end
}
...some more function code...
}
note: you need to return a relevant data type, if applicable. void functions don't need to return anything, int functions need to return an integer, string functions need to return a string, etc.
Read up on how 'return' works in C++, it's pretty straightforward and might help in the future if you want to terminate a function in a specific spot.