Woah, this really seems to be a massive issue for a lot of people.
There are lots of threads on this, and I - myself - was a culprit of not searching too much.
I had the same issue, and it was very annoying; I am pretty retentive, so I cannot go to sleep if my system is not doing what my system should be doing.
The issue with the system not going to sleep can be understood, generally, by using the POWERCFG application.
Next time your system does not go to sleep when it should open up COMMAND PROMPT.
You may have to open up COMMAND PROMPT with administrator rights, and the best way to do this is to (bottom left) SEARCH PROGRAMS AND FILES, then type in COMMAND PROMPT, then hover over COMMAND PROMPT and press CONTROL+SHIFT+ENTER; this will allow for the correct privileges.
Type POWERCFG -REQUESTS to see a list of potential culprits that are causing the system not to go to sleep.
For me, it was an audio stream driver that was not properly closed; sometimes Steam can cause this issue. However, you can override this. For instance, given some DRIVER name on that list (POWERCFG -REQUESTS) you can use the command: POWERCFG -REQUESTSOVERRIDE DRIVER [some_driver_name] SYSTEM; now the system will ignore this and sleep when it should sleep.
This might not necessarily be your issue, but I sure know it was mine, and without the help of these forums I would have never solved this issue.