proper shutdown with ctrl-c in the multithreaded case