Is there a way to return from a function from within a thread?

There has been this other recent thread: How to early return from inside a @threads loop

(I think the safest way to deal with that is to use a flag to exit from the workload of the chunk assigned to each thread, splitted at a higher level)