Before you attempt the attack, you chose whether to do the consumption as part of the attack. If you do, you also chose if you want to include the effect as part of the consumption. If you decide to consume the element, you will gain the XP (it is mandatory), even if the monster dies or you decided not to include the Stun.