Rewrite and fix exit on SIGINT