Given that you mentioned the 3rd party software, you probably know this, but I think even the 2019 MacBook Pro supported working with the laptop closed--but it requires the laptop to be charging, otherwise it will just go to sleep.
I, too, downloaded the 3rd party app ("Amphetamine"?) to allow it to stay on when closed and unplugged. As far as I can tell, it doesn't work at all.
There is a builtin cli tool “caffeinate”. Prefixed to a command it will keep the machine awake until the command exits, on its own it will keep the machine awake indefinitely.
I, too, downloaded the 3rd party app ("Amphetamine"?) to allow it to stay on when closed and unplugged. As far as I can tell, it doesn't work at all.