In order to fix this problem you may first try to flash, restore or update the device firmware, you may use a higher versions available like flash file rm-495 7.95, we already tested it for Nokia 5130c Xpressmusic.
Sometimes a software calibration doesn't fix the problem, like you succesfully flash the phones firmware many times using your flashing device but the problem still exits. Some problem is cause by a faulty hardware components. The solution below shows some components that if become faulty or cause by an oxidation it will result to auto shut off problem
The keypads ESD/EMI filter if shorted or oxidized, it will cause the phone to hang up or frozen and the keypads doesn't work and also shut off the phone, it is because the power key is also connected to it.
You may clean it first, or rework it.