MacBook Pro shuts down while in "Login Window" I have run into this issue a couple of days ago and it keeps happening. MacBookPro in question is a 13" 2016 model with Touch Bar running macOS Mojave 10.14.1 (18B75).

If I lock my MacBook with Login window and leave it for some time (it looks like it has to be more than 1 hour but I am not certain) then it shuts down. It doesn't wake up and I have to either reconnect power cable or press power button to turn it on. MacBook is constantly connected to power supply. Energy Saver parameters (for Power Adapter) set do not allow MacBook to sleep:


Prevent computer from sleeping... - checked
Turn display off after - Never  


I have checked logs and unfortunately I cannot make anything certain out of them. What looks suspicious is this:

Dec  5 09:47:43 mac com.apple.xpc.launchd[1] (com.apple.powerd.swd): Service only ran for 0 seconds. Pushing respawn out by 30 seconds.
Dec  5 09:48:13 mac com.apple.xpc.launchd[1] (com.apple.powerd.swd): Service only ran for 0 seconds. Pushing respawn out by 30 seconds.
Dec  5 09:48:43 mac com.apple.xpc.launchd[1] (com.apple.powerd.swd): Service only ran for 0 seconds. Pushing respawn out by 30 seconds.
Dec  5 09:49:14 mac com.apple.xpc.launchd[1] (com.apple.powerd.swd): Service only ran for 1 seconds. Pushing respawn out by 29 seconds.
Dec  5 09:49:45 mac com.apple.xpc.launchd[1] (com.apple.powerd.swd): Service only ran for 2 seconds. Pushing respawn out by 28 seconds.
Dec  5 09:50:14 mac com.apple.xpc.launchd[1] (com.apple.powerd.swd): Service only ran for 0 seconds. Pushing respawn out by 30 seconds.
Dec  5 09:50:45 mac com.apple.xpc.launchd[1] (com.apple.powerd.swd): Service only ran for 0 seconds. Pushing respawn out by 30 seconds.


Which usually occurs around the time the MacBook "starts sleeping" that leads to shutdown (but also scattered in smaller quantities in logs.)

I have already tried resetting the SMC but to no avail.

Does anyone have any ideas?
I would probably start with testing to see if this behaviour is replicated when booted into Safe Mode and if the issue persists then running Apple Diagnostics.

Boot into Safe Mode 

Follow these steps to boot your Mac into Safe Mode: 


Fully shut down your MBP 
Restart your MBP 
Immediately press the Shift key and keep it down 
Let go of the Shift key when you see the login window (NOTE: If you have FileVault enabled you may need to log in twice). 
Take a note of what happens (i.e. does your MBP still end up going to sleep, etc) 
Exit Safe Mode by restarting your MBP as normal 
Test again when booted normally 


If the problem doesn't occur while booted into Safe Mode, let me know and we'll go from there. 

If the problem persists, proceed with running Apple Diagnostics.

Run Apple Diagnostics

Follow the steps below to run Apple Diagnostics:


Fully shut down your MBP
Restart your MBP
Immediately press the D key and keep it down until you see the Diagnostics screen appear
Wait for Diagnostics to finish (this typically only takes a few minutes)
Once complete, one of two things will appear on the screen:


a No issues found message
a brief description of any errors found plus further instructions

If the diagnostics test does find errors, take a note of what they are


Note: If pressing and holding the D key at Step 3 doesn't work, start again at Step 1 and, at Step 3 press and hold both the OptionD keys instead. This will try and run diagnostics from the internet instead, so you will need to allow more time for it to complete. 

Regardless, take a note of what happens and let me know how you went.

[UPDATE]

Since we've established the problem is not occurring when booted into Safe Mode then it's time to investigate login items, fonts, and kernel extensions. 

Investigating login items, fonts, and kernel extensions

Let's start with Login Items:


Startup normally
Go to System Preferences > Users &amp; Groups
Select the Login Items tab
Take a note of your Login Items 
Now remove all of them by highlighting them and clicking on the - button below
Restart your computer


Now your Mac will boot up without those login items loading. Test to see if you can use your Mac without it going to sleep, etc:


If you can, you know one (or more) of the Login items were causing the problem. You can then add them back in one by one until you've identified the culprit. Problem solved.
If the problem does persist, it's either a problem with fonts you've installed yourself or with a 3rd party kernel extension. A little more info below:


Fonts:- You can remove any of the fonts you've installed yourself to see if this makes a difference. For more info, read the following Apple resources:


How to install and remove fonts on your Mac
Mac OS X: Font locations and their purposes


Kernel Extensions:- You can open Terminal (found within your Utilites folder) and enter the following command:

kextstat | grep -v com.apple

The above command will list 3rd party kernel extensions (you may need to stretch the Terminal window so it's easier to read). Look for anything you don't remember installing, or something that belongs to software you've removed, or just anything that looks out of place. Remember though, this is a list of 3rd party kernel extensions and therefore any of them could be causing the problem.