Fixed an oversight in AgentSetControls. storeAndMakeAgent now closes file handles.