But what if you want to prevent MacBook from sleeping even when you close its lid? You can use the macOS System Preferences, use third-party apps, or use the Terminal.
You may want to keep Mac from sleeping when you are downloading big files, performing Time Machine backup, rendering a video file, and in other similar situations.