MacBook Pro 2011 logging itself out after a period of inactivity

Solution 1:

System Preferences -> Security and Privacy -> Unlock the settings -> click the Advanced button -> Disable the logout option

enter image description here

Solution 2:

I believe I discovered the culprit. The "security" settings have a "Log out after "x" hours of inactivity". It was checked on my MBP, but disabled visually due to the settings being locked. This is probably why I wasn't paying attention to it.

Unchecking this option, and letting run overnight, it did not try to log out. Problem resolved.