macOS closes all my applications when I lock my screen
Open System Preferences from the Apple menu in the top-left corner. Open the &quot;Security &amp; Privacy&quot; preference pane. Click on the &quot;Advanced...&quot; button in the bottom-right corner. You may need to unlock the pane using the padlock icon in the bottom-left corner.
I think you'll find &quot;Log out after XX minutes of inactivity&quot; ticked. Untick it.

Reference: https://apple.stackexchange.com/a/140077