You might find that when you choose to sleep your Mac by closing the lid or choosing Sleep from the menu, every now-and-then it refuses to do so. This is typically a quick fix, as luckily it’s not hard to get to the bottom of this problem. Ever since the availability of OS X Yosemite, you can simply choose from the View > Column menu when you’re on Activity Monitor’s CPU tab to show which processes are preventing sleep. Click this column header to sort and to easily find which apps are keeping the Mac awake. Quit them as necessary.
Activity Monitor is found in the Applications > Utilities folder.