Fix main logic in agent caused by merge.

Additionally:
- Added documentation to reduce chance of logic in the future.
- Reinstated idle logic in check_running.
- stdout and stderr also collected on CANCELED.
- Removed some commented out code
Merge branch 'experimental' of github.com:radical-cybertools/radical.pilot into experimental