Sharing settings on your Mac, such as printer or file sharing, can prevent your iMac from entering sleep mode. To fix this, go to System Preferences, click on General, and navigate to Sharing. Disable any unnecessary sharing services to prevent interference with sleep mode.