Record termination time in state.

Supercedes pull #1946
Merge pull request #2164 from pnasrat/add-finished-time

* Runtime: Record termination time in state.