NXP-13452: avoid random error: Element is no longer attached to the DOM