only os.Exits on error

Fixes error in tests introduced by #1812