Added signal handler for graceful shutdown.