break void function when the condition is met

If you want to exit a function of return type void, use the return statement (without a value).