Dsi xl randomly shuts off or freezes

My Nintendo DSI XL turns off when you close it and go to re-open it and then a lot of times it freezes if you touch anywhere around with the game cartridge is, very frustrating looking for some help on how to fix this problem thank you.