Does XYZ Effect resolve?
In all scenarios you mention XYZ Effect resolves
Why? Because neither MST, Cosmic Cyclone, or that card that returns to deck have the ability to negate effects; they "just" destroy the card, but never negated its activation and thus it resolves.
This situation is similar to one answer I gave recently. The only cases where a card like MST or similar (that just destroys) can prevent a spell/trap card effect from activating is if that spell/trap card has a continuous effect.
For example, if your opponent activates Fire Formation - Tenki and you cast MST on it your opponent will not be able to search for a beast-warrior. This is because cards with continuous effects must remain face-up on the field to resolve their effects.