added emergency cleanup on SIGINT and panic