trap ctrl-c and heartbeat