Android dies at 20% battery?
There could be three reasons to this (not in any order)  :


Battery lived it's life.
Fuel Guage drivers corrupted.  To rule this out, i suggest back up your data and with your recovery wipe clean all Cache and system and flash stock(not sure if you cleaned fully when you flashed a ROM)  If the problem continues, it is likely that it is not a driver corruption issue. 
Hardware of battery charging chip gone bad. One possible way of checking this is to see if it is charging and discharging fully in safe mode. If  it  does unlikely to be hardware issue 


I would recommend step 2 first and then if possible borrow a battery to check if it is a case of  battery end of life. 

All the best and do post the conclusion