Putting a system to sleep is far more convenient than shutting it down between uses, because it allows you to save the machine's running state, to quickly pick up from where you left off without having to load the OS and programs again. While sleeping is usually a fairly quick process, sometimes problems can occur that cause it to take a long time or even hang. In these cases, even if you close a laptop's screen the system will stay running, and will then either just continue to run normally or not respond to any user input.
Unfortunately, sleep problems can be rooted in a number of areas, so it may be difficult to pinpoint a specific cause, but luckily you can do a number of tasks to hopefully correct the problem.
Run general maintenance routines
A general task you can always do whenever a system is running slower than normal is to perform , which include correcting permissions issues and clearing temporary files and caches. In doing a general maintenance routine, you will boot to Safe Mode, where you might try putting the system to sleep to see if it happens quicker when the system is not loading third-party extensions and add-ons you may have installed.
Reset PRAM and SMC
The system's parameter RAM (PRAM) and system management controller (SMC) both contain hardware settings that may influence how the system sleeps. Resetting them will establish default settings again, which may help clear a long sleep instance. To reset the PRAM, restart the computer with the Option-Command-P-R keys held down. Hold the keys until the system automatically rests a couple of times, and then release them and allow the system to boot normally. To reset the SMC, see this Apple Knowledgebase article.
Check peripheral devices
If you have any peripheral devices attached to your system, ensure they are not the cause of the sleep problems. Sometimes an active peripheral device can delay shutdowns and sleeps, so try unplugging them before sleeping to see if the delays go away. If so then you can try further looking into each device's settings or drivers to see about fixing the problems.
If you have active print jobs or ones that are showing errors, the system may also take a long time to sleep. Go to your Print & Fax system preferences, select your printer(s), and then click the "Open Print Queue" button to show the print jobs. Cancel any that have not completed, and try putting your computer to sleep again.
Adjust system services
As with active print jobs, activity in other background services can cause the system to hang or pause when performing tasks like shutting down or sleeping. You can troubleshoot these by turning off Wi-Fi or Bluetooth a few seconds before putting the system to sleep, or also by disabling any sharing services you have enabled in the "Sharing" system preferences. Even if you do not have any active sharing sessions, if there is a problem with one of these services then it may still keep the system awake when trying to sleep.
Check hardware settings
OS X supports a number of options for putting the system to sleep, including keeping the system alive in RAM but running at a low-power state, or by writing the RAM's contents to the hard drive so the system can essentially be shut off to save even more power than a standard sleep. The setting that determines this is the "hybernatemode" setting in the System Management Controller, which can be checked by running the command "pmset -g" in the Terminal. When this is run you should see a list of the SMC's variables, and hybernatemode should be at its default setting of "3" on laptops, and "0" on desktop systems. If it is not, then run the following command in the Terminal to change the setting:
sudo pmset -a hybernatemode NUMBER
In addition to the hybernatemode settings, you can also try removing the system's sleep image file, which is the file used to store memory contents. Doing this will cause the system to re-create the file when it is next put into sleep mode, which might result in a faster sleep time. To do this, run the following command in the Terminal:
sudo rm /var/vm/sleepimage