graceful shutdown with and without saving state