macOS Sierra: Require a password after waking your Mac
To keep the information on your Mac secure when you are away from it, set it to require a password when it wakes from sleep. When you return to your Mac, enter your login name and password to continue working.
Choose Apple menu > System Preferences, click Security & Privacy, then click General.
Select “Require password… after sleep or screen saver begins.”
Click the pop-up menu and choose the time that passes before a password is required.
Locking the screen doesn’t prevent other users from turning off the Mac, restarting it, and logging in. If you think this could happen, and you use apps that don’t automatically save your changes, be sure to save your work before you leave your Mac.