OSX machines have a keyboard shortcut to put the machine to sleep, which suspends processing, downloads, and other operations.
OSX machines also have a Lock function which can be triggered via a menu option. It can also be triggered by running a specific command:
/System/Library/CoreServices/"Menu Extras"/User.menu/Contents/Resources/CGSession -suspend
How can I lock my OSX machine with a keyboard shortcut?