send a non-zero exit code if script terminates early

The default behaviour for process.exit() sends an exit code of 0. This PR sends an exit code of 1 in the cases of error to indicate when the script has failed to complete