Catch signals for graceful shutdown