wait for agent close