Check for agent aborting contexts on each stack pop. Add test.

Close #2316, #3114, #3003

(cherry picke from commit 432b3daa6c547e30164089d538974e3484305251)
ChangeLog update