When someone presses Ctrl-c when running your Ruby script, the signal can be caught by Ruby:

trap "SIGINT" do
  puts "Exiting"
  exit 130
end

130 is the common exit code for terminating with Ctrl-c.