How to parametrize the sleep/hibernate behavior of a MacBook Pro
You need to open System Prefences > Energy Saver. In the "Battery" tab, you'll find a slider for "Computer sleep". This determines the amount of the time the computer stays awake when idle (i.e. user not actively at the computer).
If you set the slider to "Never", it will let operations continue indefinitely (even though the display itself is blanked). Ofcourse operations will stop when the battery runs out.
When you close the lid on the computer, the Mac will go to sleep as usual.