I currently use Ubuntu 22.04.1 LTS The problem does not occur on windows (I have dual boot) and I have never seen this happen in the past version of ubuntu that I had installed.
When connecting an external monitor via HDMI (I don't have other cables to test, just HDMI), the laptop screen flashes and it seems that the session is disconnected, after putting the password all programs appear closed.
The same happens when I close the lid of the laptop, when I reopen the session appears logged off, I type my password and all programs appear closed.
The issue also occurred after some time without touching the laptop, I had to disable the Screen blank option (turn the screen off after a period of inactivity, which technically shouldn't log off, just save energy) in the power options.
I believe it must be a problem with the NVIDIA drivers, my notebook has a 1650.
I don't know how to track this issue or how to resolve it, all the threads I found are not resolved.
1- I mentioned NVIDIA, because it seems to be a video problem, and searching for similar problems I found some alternative solutions related to NVIDIA as in: Black screen after i close the lid and reopen
2- The drivers I use are the ones that came with Ubuntu
3- The problem always occurs since the first day I used Ubuntu 22.04.1 LTS on that laptop
4- When consulting the system monitor, using the example of google chrome, no open chrome processes appear, and when I open chrome again, the notification appears that the program was forcefully closed and asks me if I would like to reopen the pages I left open.