move the shutdown logic into monitoring_agent