All perfect praise be to Allah, The Lord of the Worlds, and peace and blessing be upon the Messenger of Allah, his family, and all his Companions.
You should know that if a person is overwhelmed with Waswas (obsessive satanic whisperings), being under an illusion that he has pronounced divorce when he had not nor does he want to initiate divorce, the divorce does not take place in any case. This is because he has no control over these whisperings. A person will be held accountable only for what he does by choice, and therefore non-deliberate mistakes are forgiven. Allah, The Exalted, Says (what means): {Our Lord, do not impose blame upon us if we have forgotten or erred.} [Quran 2:286] It was authentically reported that Allah, The Exalted, Said in a Qudsi Hadeeth: “I have done so (as requested).” [Muslim]
There is no doubt that disregarding these whisperings is required, and it is one of the most effective ways to treat them. Ibn Hajar Al-Haytami was asked about the possibility of treating Waswas. He replied: “There is an effective remedy, namely, to disregard these whisperings completely.” This means that you should ignore them completely.
If you are not certain that you uttered these words willingly, the basic rule is that your liability is cleared and your marriage bond is intact until proven otherwise. This is based on the Fiqhi principle that reads: “Certainty is not overruled by doubt (i.e., what is proven with certainty cannot be negated based on mere doubts).” This is a very beneficial principle for the one who is plagued with Waswas.
Allah knows best.