Overheating, software errors, incorrect permissions and malfunctioning hardware can each cause a MacBook to suddenly shut itself down. Fixing software glitches or heating problems can often be fixed yourself at no cost, but if an internal component is malfunctioning, you may have to take the MacBook in for repair.
If your MacBook suddenly shuts off, the reason is usually that the battery has run low. Make sure the power adapter is firmly connected to the MacBook -- sometimes the magnet sticks to the power slot but isn't completely inside it. A light on the magnetic adapter shines when it is powering the computer. A battery indicator is located on the top of the Mac's desktop indicating its charge or if it is plugged into a power source. As a battery is used, its ability to keep a charge is reduced so if you have had your MacBook for a few years, you may need to replace the battery.
Video of the Day
If too much heat builds up inside the MacBook, it may shut itself off to prevent damaging its internal components. Keep your laptop in a cool area and place it on a flat surface to allow proper air flow. Clean out the air vents at the back of the MacBook with a can of compressed air to ensure the laptop is able to cool itself. MacBooks should not be used in temperatures above 95 degrees.
Disk Permissions and Errors
If the shutdown is not hardware-related, an error in the software could be the culprit. Open your Applications folder and then the Utilities subfolder. Double-click "Disk Utility." Select "Macintosh HD," then click "Repair Disk Permissions." When this is done, click "Verify Disk." If any problems turn up, click "Repair Disk." If your computer shuts off before giving you access to it, press "Command-R" after turning it back on. This forces the MacBook to run OS X Recovery, which will guide you through the repair process.
MacBooks store certain settings and data in a memory area called PRAM, which persists even if your computer is turned off or unplugged. If anything is wrong with your PRAM, any of its settings could cause your computer to experience errors. Turn off your computer; then restart it, holding down the "Command," "Option," "P" and "R" keys simultaneously before the grey Apple logo screen appears. Continue to hold down all four keys until the computer restarts and you hear its start-up chime again.
Occasionally, the hardware inside your computer can deteriorate or simply be defective. The MacBook's logic board is one of the most common sources of hardware problems. If you have repaired your operating system and performed all the other steps above, you have narrowed causes down to where the problem almost exclusively must be a hardware problem. Unfortunately, if this is the case, the hardware itself will need to be replaced, meaning that you'll need to make an appointment with an Apple store.