After some investigation, I found out that this is happening when the trusted helper doesn't call mir_prompt_session_release_sync() when both B and C have quit. By adding that call, everything works fine, though sometimes it's still possible to see window B for a fraction of a second.
I'll keep the bug open if you still want to address this last issue, but anyway this bug is not as serious as I initially thought.
After some investigation, I found out that this is happening when the trusted helper doesn't call mir_prompt_ session_ release_ sync() when both B and C have quit. By adding that call, everything works fine, though sometimes it's still possible to see window B for a fraction of a second.
I'll keep the bug open if you still want to address this last issue, but anyway this bug is not as serious as I initially thought.