You can use FSCK (File System Check) tool to diagnose and repair a corrupt Mac X file system, including your system showing a load bar for Mac X but suddenly turns off your machine.
1. Boot to Single User Mode. Reboot your mac and hold down Command + S keys. You will boot to a black screen that has command line parameters.
2. After booting, type enter once. You will be at a command prompt with localhost:/ root#
4. Re-run fsck –fy 2 to 3 times before you receive the message “** The volume XXX appears to be OK.”
5. Type reboot to boot back to Mac X. Cross your fingers and let’s hope the repair worked.