Add method for graceful shutdown