So the exit function states: return causes the piston to end evaluation stage and set the piston state to the value provided.
I don’t know what that means. I’m used to simply stating in programming, if this happens then exit, and the loop will be interupted and end. So what is the value that im supposed to put in to make it end?
The value provided will not in and by itself make the piston exit; that is the function of the Exit command you used. This value is the equivalent of a programming exit code, akin to say a 1603 on a MSI.
As mentioned, it simply sets the piston state with the provided value, so it can be something like “Aborted due to condition X not being met…”
You must disable automatic piston state for this to function.