fix crash on domain restart in Agent, also have Agent properly shutdown on call to Script.stop()

* fix crash in agent on domain restart - closes #2254
* fix agent not returning back to available AC queue if script calls Script.stop() - closes #2434