Fix runaway emulator subprocess

This commit fixes the issue of the emulator subprocess continuing to run
after the main process exits by adding an exit handler which terminates
the subprocess.
Merge pull request #11 from zhemao/master

Fix runaway emulator subprocess