Occasional login loops

CTL ALT F2 to enter terminal. Copy paste the code below into terminal window and hit enter.

sudo apt-get install gnome-tweak-tool

Launch the app by typing in terminal...

gnome-tweaks

Find the section under POWER, and under the LID SWITCH setting, tell it to do nothing. Hope this helps.