You can set your Mac to automatically log out of your user account when your Mac is left untouched for a set amount of time. You can turn this feature on or off from the Security & Privacy pane of System Preferences.
Use these steps if you don't want to be logged out automatically:
- Choose System Preferences from the Apple menu.
- Click the Security & Privacy icon in the System Preferences window.
- If the lock icon shown in the lower left corner of the window is locked, click it and enter an administrator name and password.
- Click the General tab.
- Click the Advanced button.
- Deselect the option, "Log out after __ minutes of inactivity."