The issue is coming from the menu still being shown (due to the animation).
One simple fix could be to disable the animation, so the menu is closed ASAP, preventing it from trying to read the Theme from an expired context.
Just put popUpAnimationStyle: AnimationStyle.noAnimation
in your PopupMenuButton