If Activity Monitor reports that WindowServer prevents your Mac go to sleep, you can try to close all the opened windows on your Mac before letting it sleep. If that doesn't work, try to update your Mac to the latest version as this issue may also be caused by system errors.