better handling of unloadAgents()