1. Always do a Nandroid backup.
How to do it?
Just turn off your phone and press the key combination of your phone to enter "recovery mode" e.g.(power + volume down). After doing so, look for the option called "backup" check the following options > [โ]system [โ]boot [โ]data
You can restore your previous rom incase of bootloops occur.
2. Flash the corresponding custom/stock rom carefully by doing it the right way.
If you're reading a thread tutorial, understand the procedure attentively before proceeding to do the work. Next, if you're watching a video tutorial, follow the tutorial step by step (I prefer pausing the video so that you can do it safely). Do these two (2) simple tips and you're flashing could be fine.
I hope you can learn from these tips and goodluck!