If a person forms the intention to stop doing an act of worship whilst he is doing it, it becomes invalid. No exception is made except in the case of Hajj and ‘umrah, which do not become invalid if the intention is cancelled or even if a person declares that he is going to stop. Rather the muhrim remains in ihraam until he has completed the rituals or he exits ihraam because of being prevented from continuing.
It says in al-Mughni (1/278): If he started his prayer with a sound intention, then he forms the intention to stop praying and exit from it, then it becomes invalid. This was the view of al-Shaafa’i. End quote.
It says in Zaad al-Mustanqi’ in the chapter on prayer: If he decides to end his prayer whilst praying or he becomes hesitant, then his prayer is invalidated. In the chapter on fasting he said: The one who forms the intention to break the fast has broken the fast.
But Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) said in al-Sharh that hesitating about ending the prayer does not make the prayer invalid. See: al-Sharh al-Mumti’ (1/486). An example of hesitating is if he hears someone knocking at the door, and he wonders whether he should stop praying or carry on?
Thus it is clear that if a person decides to stop the act of worship, it becomes invalid, but if that was simply a thought that crossed his mind, it does not invalidate the act of worship.
Based on this, if the idea of stopping the fast simply occurs to one, it does not invalidate the fast until he decides and forms the intention to break the fast.
Similarly, if whilst doing wudoo’ he becomes uncertain as to whether urine has come out of him, and he pauses and looks, but does not intend to stop doing wudoo’, and he does not find anything, then his wudoo’ is not invalidated.
Similarly if he intends to stop doing wudoo’ his wudoo’ is invalidated, and it is not permissible for him to complete it, rather he must start all over again.
It says in al-Insaaf (1/151): If he cancels his intention whilst purifying himself, what he has already done is invalidated, according to the correct view. This was the view favoured by Ibn ‘Aqeel and by al-Majd in his commentary. And it was said that what has already been done is not invalidated thereby; this was stated by al-Musannaf in al-Mughni. End quote.
But one must beware of waswasah, because the shaytaan may come to a person and make him think that something has come out of him, and the person may get carried away with that and hardly be able to do any act of worship without doubting about it, which may cause him hardship and distress. Please see question no. 62839.
And Allaah knows best.