Fix memory leak in unix/main.c

To exit cleanly if sys.exit has been used, a global flag should_exit_g indicates that main() should return with exit_val_g.