Muslims can have painful deaths too. Because the agonies of death is another way to purify the muslim from the sins that he may have commited in his life. If the agonies of death are not sufficient to purify a muslim, then the time in the grave he will be punished until he is purified. If that does not suffice, the Day of Judgement. If that too isnt enough, then the Hell Fire until it purifies him completely and he enters Paradise.
For the unbeliever, they have an evil death because their souls know what is coming to them, so the sould spreads through the body not wanting to come out, and it gets ripped out of their body. Refer to Surah Naziat, verses 1-2.
Imam Ahmad recorded that Abu Hurayrah said that the Prophet said,
The angels attend the dying person. If he is a righteous person, the angels will say, `O pure soul from a pure body! Come out with honor and receive the good news of rest, satisfaction and a Lord Who is not angry.' The angels will keep saying this until the soul leaves its body, and they will then raise it up to heaven and will ask that the door be opened for the soul and it will be asked, `Who is this' It will be said, `(The soul of) so-and-so.' It will be said, `Welcome, to the pure soul that inhabited the pure body. Enter with honor and receive the good news of rest, satisfaction and a Lord Who is not angry.' This statement will be repeated until the soul reaches the heaven above which there is Allah. If the dying person is evil, the angels will say, `Get out (of your body), O wicked soul from a wicked body! Get out in disgrace and receive the news of boiling fluid, a fluid dark, murky, intensely cold and other (torments) of similar kind - all together - to match them.' This statement will be said repeatedly until the evil soul leaves its body. The soul will be raised up to heaven and a request will be made that the door be opened for it. It will be asked, `Who is this' It will be said, `(The soul of) so and so.' It will be said, `No welcome to the wicked soul from the wicked body. Return with disgrace, for the doors of heaven will not be opened for you.' So it will be thrown from heaven until it returns to the grave. So the righteous person sits and similar is said to him as before. And the evil person sits and similar is said to him as before.) (Taken from Tafsir Ibn Kathir, Surah Al An'am, Chapter: The Servants are in Allah's Hands Before and After Death)