Sheikh `Abdul-Majeed Subh, a prominent Azharite scholar, states: “It is not an Islamic tradition but a Muslim may do so in gratitude for Allah for His blessings or in the hope that Almighty Allah averts him harms or ailments.

So, the issue depends on one’s intention. If one faced good matters and he slaughtered an animal in gratitude for Allah, it is good. Similarly, if he faced a tragedy or an evil matter and he slaughtered an animal hoping that Almighty Allah removes the harm this is also good. We read in the Prophet’s hadith, “Treat your sick persons by giving charity.””