signal handler for ctrl+c

for a proper shutdown
Please make this function private, i.e. prefix it with `_`. Otherwise I'm fine with merging.