If your system stops responding and you're unable to shut down or restart your MacBook through the Apple menu, you can perform a hard reset to restore operation to the computer. A hard reset has no effect on your personal files or settings and simply forces the computer to turn off. After resetting your MacBook, you should boot into Safe Mode to run diagnostics on your system and check for problems that could be affecting your computer's performance.
Press and hold the power button for five to 10 seconds, and then release the button when the system shuts down.
Disconnect the power adapter and any other cables or devices attached to the Mac if the computer won't turn off.
Close the lid and turn the computer over. Lift the release latch located next to the access door.
Open the access door and pull up on the battery tab to extract the battery from its compartment.
Flip the computer over, and then press and hold the power button for five seconds.
Return the battery to its compartment and then close the access door. Reconnect the power adapter and then turn on the computer.
Press the "Shift" key when you hear the startup chime to boot into Safe Mode.
You can't remove the battery from the MacBook Air or MacBook Pro Retina. The device is built into the computer.
Before you perform a hard reset, attempt to close any applications that may be causing system instability, or wait several minutes to see if OS X regains functionality.
Depending on your model of MacBook, you may need to slide a pair of battery release latches, or insert a coin into the battery lock and turn the coin clockwise, to eject the battery.