If you want to exit from a console program but return an exit code to the operating system (other than the default of zero), then the usual way is to use one of the patterns for the Main() method which return an int:
static int Main()
{
//...
if (someErrorHasOccurred) return 1; // say
//...
return 0;
}
Environment.Exit(1) would achieve the same result but is best restricted to situations where an abrupt exit is needed because it's difficult or impossible to get back to the Main() method to exit gracefully.