The SMC, or System Management Controller, handles many of the physical components on your Mac. An issue with the SMC can prevent your power button from working properly, or cause general slowdowns. If none of the steps above solved your problem, reset the SMC:
Laptop with non-removable battery — Shut down your computer and plug it into a power source. Using the left side of the built-in keyboard, hold down ⇧ Shift + Control + ⌥ Option while pressing the "Power" button, then release all keys, and finally press the "Power" button again. Laptop with removable battery — Shut down your computer. Unplug the power adapter and remove the battery, then hold down the "Power" button for five seconds. Release the "Power" button, reinsert the battery, and plug in your computer to a power source. Press the "Power" button. Desktop — Shut down the iMac and unplug the power cord. Wait fifteen seconds, then plug it back in. Wait five seconds, then press the "Power" button.