How to stop a function from a different function

Hello. I know this has been asked before but none of those have definite answers so I’m just gonna ask myself.
For example let’s say we have this

local function typeTest()
	print("1")
	wait(10)
	print("2")
	wait(10)
	print("3")
end

I want to stop this function before it prints out 3.
You can’t use return since we stated we want to do this from a different function, so what could I do to stop it?

It seems to me that the only way is to use flags

local function typeTest()
	print("1")
	wait(10)
	print("2")
	wait(10)
	if stop then
		return
	end
	print("3")
end

If I have to use flags, this means in my very long function I have to recheck this over and over, which seems like it wouldn’t be very good. But if this is really the only way then so be it.
I’ll wait for more answers though, see what comes up.