Find out what’s preventing the Mac from sleeping

In a terminal

pmset -g assertions

If there are any processes preventing sleep, you will get a list with the PIDs of the preventing processes.