fix stop functionality to handle Ctl-C