All you have to do lock your Mac to keep them out.
There are several ways to lock your Mac.
you’ve got the option to have it lock automatically when your display goes to sleep.
it’s possible for you to lock it with a keyboard shortcut.
Here’s how to do all of this, and more!
Set the associated dropdown menu to “immediately.”
If you’re using a newer Mac where the Power button is a key, just press Control+Shift+Power.
If you’re using an older Mac with an optical drive, press Control+Shift+Eject instead.
Just like that, your Mac will be locked.
Head to System Preferences > Keyboard, then poke the “Customize Control Strip” button.
Drag the Lock Screen button off the bottom of your screen and onto your Touchbar.
If you like the feature, you might use it to lock your screen.
Then, head to System Preferences > Mission Control and pick the “Hot Corners” button.
Here, you’re free to set any corner to “Put Display to Sleep.”
It’s entirely up to you.
Either way, your Mac will be locked when you trigger this corner.
Head to Applications > Utilities > Keychain Access.
From the “Keychain Access” menu, grab the “Preferences” command.
In the “Preferences” window, check the “Show keychain status in menu bar” option.
You’ll now see a lock icon on your menu bar.
Click it and you’ll see the option to lock your screen.