Implemented signal handlers for SIGINT and SIGTERM.