To turn off the sleep mode
Open Power Options by clicking the Start button, clicking Control Panel, clicking System and Security, and then clicking Power Options.
Under the plan that you want to change, click Change plan settings.
On the Change settings for the plan page, choose the display and sleep settings that you want to use when your computer is running on battery (if applicable) and when it's plugged in.
Ideally depending upon your power setting the os automatically goes into sleep mode if there is no user activity, even if you have a download, installation or scan going on this is because according to the os these all are system activity and not user activity hence it will go to sleep if no user interaction is recorded and this is applicable only on non windows applications because playing a video on windows media player will not trigger the sleep mode even if there is no user interaction(like you not using the keyboard or mouse)
source : Microsoft Community