How can I throw an error / terminate the flow from within a custom function?

How can I throw an error / terminate the flow from within a custom function?

As the subject says. I would like to be able to terminate a flow from within a custom function if certain conditions are not met. I know I could hook a decision box to the output of my custom function and check return variable, but hoping there is a more elegant solution.