how to end a c++ program early

C++
void func( bool d )
{
    if( ! ( d ) )
        return;

    //Load of code here that you don't want to execute if the above is incorrect.
}
Source

Also in C++: