Is it permissible for one to masturbate in order not to commit fornication?
This is called committing the milder of the two evils such as eating a carcass in fear of death, and this happens when committing fornication is very likely to occur.
Is it obligatory for a wife who has been abandoned for many years to observe the waiting period (iddah) after her husband passes away?
If her husband passes away, the wife is required to observe the waiting period (Iddah), even if he had abandoned her, because she is his wife and inherits from him, so she must observe the iddah after his death. And Allah Knows Best.
What is teh ruling on thoughtless oath?
One who swears by Allah unintentionally and isn`t determined to fulfill his oath, nothing is due on him. Allah, The Almighty, Says (What means): "God will not call you to account for thoughtlessness in your oaths, but for the intention in your hearts; and He is Oft-forgiving, Most Forbearing." [Al-Baqarah/225]. However, it is dispraised for a Muslim to swear frequently.
Is prayer nullified by having thoughts while performing it?
Prayer isn`t nullified by having thoughts while performing it, provided that the praying person offers all of its pillars and meets all of its conditions. However, the reward decreases significantly in the absence of reverence since a praying person is rewarded according to the attentiveness of his/her heart during prayer.