The option is found in the System Preferences window as shown below
– Security & Privacy General and then
– Advanced dialog.
Choose Apple menu - System Preferences - Click on Security & Privacy - Click General and - Click the on the lock icon 🔒to unlock it - Enter an administrator name and password - Click Advanced
Uncheck “Log out after minutes of inactivity as shown below and click Ok
Finally Click on the Lock again, to activate the lock as shown below