Make sure to exit with error codes when necessary