Add graceful shutdown handler