Restore context on exception