context_tracking: Restore correct previous context state on exception exit