Correctly reporting errors and exit codes in autopilot