By default, your Mac is set for maximum efficiency. That means it tries to preserve energy whenever and wherever it can, especially if you’re on battery power. So when it detects that you’re no longer using your computer, it automatically goes to sleep. While that will save you some battery life, it’s not ideal in every situation.