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

Close #2316, #3114, #3003