Install sigint handler for program mode too

In a non-REPL case, the program currently terminates upon a Ctrl-C without calling the `atexit` functions.

This patch:
- installs the sigint handler for both the REPL and Program modes
- In program mode, the master process exits after calling the `atexit` functions.