C# end-vba equivalent

Hello @tous,
I'm looking for the equivalent of the "end" function of the vba to implement it in a C# Macro.
(function that can be called from a winform and also from a procedure in the main program)
I found "Environment.Exit(0)" which works to the disadvantage of sending me a message in solidworks, if you have a better solution thank you in advance,

Hello
In which case do you want to use this?
If you're in the main method, you can use a "return".

Hello @Konti
Thank you for the proposal, Basically I am looking to stop the program from a function in my main program also from userform (in vba the function can be called from anywhere) ,
The return function doesn't do the trick, it can only return the function where it's registered,

I think I'll try with the exceptions, it seems to me that it's doable.

Hello
The try{} catch{} block allows me to exit the program in a smoother way.