Fix bug JAH-865

Call sys.exit on exception from main loop.

Change-Id: Ie03acbd3b6f493aeb2288c4fbe0062738cc1b75e