Allah Subhana wa Taala says in the Qur'an:


Surah An - Nisa Verse 78

Wherever you may be, death will overtake you - even though you be in towers raised high. "Yet, when a good thing happens to them, some [people] say, "This is from God," whereas when evil befalls them, they say, "This is from thee [O fellow*man]!” Say: "All is from God." What, then, is amiss with these people that they are in no wise near to grasping the truth of what they are told?

...........................

Surah An - Nisa Verse 97

Behold, those whom the angels gather in death while they are still sinning against themselves, [the angels] will ask, "What was wrong with you?'' They will answer: "We were too weak on earth." [The angels] will say: "Was, then, God's earth not wide enough for you to forsake the domain of evil?" For such, then, the goal is hell - and how evil a journey's end!

...........................

Surah An - Nisa Verse 100

And he who forsakes the domain of evil for the sake of God shall find on earth many a lonely road, as well as life abundant. And if anyone leaves his home, fleeing from evil unto God and His Apostle, and then death overtakes him - his reward is ready with God: for God iss indeed much-forgiving, a dis*penser of grace.

..............................

Surah Al - Imran Verse 154

Then, after this woe, He sent down upon you a sense of security, an inner calm which enfolded some of you, whereas the others, who cared mainly for themselves, entertained wrong thoughts about God - thoughts of pagan ignorance - saying, "Did we, then, have any power of decision [in this matter]?" Say: "Verily, all power of decision does rest with God" - [but as for them,] they are trying to conceal within themselves that [weakness of faith] which they would not reveal unto thee, [O Prophet, by] saying, "If we had any power of decision, we would not have left so many dead behind." Say [unto them]: "Even if you had remained in your homes, those [of you] whose death had been ordained would indeed have gone forth to the places where they were destined to lie down." And [all this befell you] so that God might put to a test all that you harbour in your bosoms, and render your innermost hearts pure of all dross: for God is aware of what is in the hearts [of men].