How to come out of fork after completion of any two processes

How can control come out of fork join after completion of any two processes with 4 processes running in parallel?

In reply to Sagar Wakle:
This should work for 2-out-of-N processes

https://verificationacademy.com/forums/systemverilog/resume-simulation-when-any-2-threads-out-3-get-completed-within-fork-joinany.#reply-78545