Options for System.exit(int)

We have a command line application in which we have used System.exit(int) to exit the program and to get the errorcode in return. We have our own errorcodes those are now greater then the integer's maximum value(2,147,483,647).

So a problem now we are facing while using System.exit(int) is that when the any error occurs and its error code is bigger then integer's maximum value (i.e. System.exit(any long int)) then Exception occurs.

Now my Question is, Do we have any other option(overiding any other method of other class etc) in which we can exit the code and get a error code on OS?

def static logout(val){
        new Logout().execute();
        logger.info("--- Exiting ---")
        System.exit(val)
}

our command line application is in Groovy.