Update agent.py

Changed terminate_self function