Catch Ctrl+C (Interrupted Signal)

Is there any way to catch a Ctrl+C and clean up before exiting a script?

I tried:

do { :delay 2 } on-error={ :put "Test" }

But that didn’t work - when you interrupt the command with Ctrl+C while it’s running, there is no output.
Any proper way to do it?

You can’t because ctrl-c is interactive.