First of all, you cannot add a complex if statement in an anonymous function. The workaround is similar to what Adam has mentioned, is that you can create a regular function and pass the function handle in. for example:
eva = evalclusters(meas, @myfunc, 'CalinskiHarabasz', 'klist',[1:6])
Additionally, the optimal cluster number is the result of evalclusters, which means you should not use that number as a condition of the clustering algorithm to stop execution. Otherwise, I personally do not know a way to stop evalcluster inside myfunc. However, if you just want to play with numbers, you can call exit() to stop the entire program. If you still want to execute something after evalclusters, then you could set a global variable and when you meet the condition, you set the variable to true and in mufunc, if that variable is true, do nothing and return. But that is rather complex and not a very good practice.