Praise be to Allah.
The scholars are agreed that stopping an obligatory prayer deliberately with no excuse after having started it is haraam.
The legitimate excuses that make it permissible to stop the prayer include those which are mentioned in the saheeh Sunnah, and those which have been determined by analogy to be similar to them or to be stronger reasons.
Among the legitimate excuses that make it permissible to stop the prayer – whether it is obligatory or naafil – are killing snakes, fear of losing one's belongings, helping one who is in distress, saving one who is drowning, putting out a fire, and warning a heedless person of something that may harm him.
If a child is crying and his father or mother are unable to quieten him down during a congregational prayer, then it is permissible to stop praying in order to quieten him down, for fear that his crying may be because of some harm that has befallen him, and for fear that the prayer of others may be spoiled because of the disturbance.
If it is possible to quieten him down with a slight movement and without turning away from the qiblah, then the woman may do that and go back to her prayer. She may, for example, move backwards to pick him up without stopping her prayer. But if she is not able to quieten him down without stopping her prayer altogether, then she should do that and there is no sin on her in sha Allaah.
It says in Mataalib Ooli al-Nuha (1/641):
It is Sunnah for the imam to make the prayer brief if something happens during the prayer that means that one of the worshippers has to stop praying, such as hearing a child crying, because the Prophet (peace and blessings of Allaah be upon him) said: “I start the prayer intending to make it long, then I hear a child crying, so I make it brief lest I cause hardship to his mother.” Narrated by Abu Dawood. End quote.
The scholars of the Standing Committee were asked:
Is it permissible to stop praying if the worshipper sees an animal coming towards him such as a scorpion or other poisonous animal? Similarly, when praying in al-Haram, is it permissible to stop praying so that he can follow his son or daughter who is about to get separated from him and lost?
If it is easy for him to get rid of the scorpion etc without stopping the prayer, then he should not stop praying, otherwise he may stop. Similarly if it is easy for him to look after his child without stopping the prayer, he should do so, otherwise he may stop it.
Shaykh ‘Abd al-‘Azeez ibn ‘Abd-Allaah ibn Baaz, Shaykh ‘Abd al-Razzaaq ‘Afeefi, Shaykh ‘Abd-Allaah ibn Ghadyaan.
Fataawa al-Lajnah al-Daa’imah li’l-Buhooth al-‘Ilmiyyah wa’l-Ifta’ (8/36, 37)
See also the answer to question no. 26230.
And Allaah knows best.