Improved Ctrl+C handling