iMac logging out whenever seemingly stressful programs are launched

The cause for your issue is most likely related to the graphics processing unit (GPU) of your iMac. This is what's commonly referred to as a graphics card.

Some games and applications will place the GPU under a much heavier load compared to others.

For example, using a word processor will not tax the GPU much at all, but using applications such as Photoshop, Maya, Render, Final Cut Pro, Motion, etc will place a much heavier burden on the GPU. I'm not familiar with Roblox, but it's likely that it's also taxing the GPU heavily.

Normally this would not be a problem, but if your Mac has a GPU that has developed a problem, it'll be enough to effectively cause it to crash in such a way that your Mac has to reboot. In this scenario it's a hardware fault that may mean repairing or replacing the GPU.

Some Mac models were more prone than others to these types of problems. For example, the 27" iMac model from mid-2011 was the subject of a graphics card replacement program for exactly this type of issue.

However, it doesn't necessarily have to be a hardware fault. Software can often cause problems. For example, it could be a conflict between software, drivers, etc or a lack of graphics memory (especially if running multiple apps simultaneously). You could try troubleshooting this further by only running one application and seeing what happens. Perhaps testing in Safe Mode may be an option as well.


Remove any CUDA and NVIDIA drivers

Since you're running macOS Mojave (or above), you should be aware that any CUDA and NVIDIA drivers you have installed aren't supported.

To remove these:

  1. Launch Terminal (found within your Utilities folder)
  2. Copy and paste the following commands, one by one, into Terminal followed by pressing enter on your keyboard. Each time you do this you'll also have to enter your Admin password.

    • sudo rm -rf /Library/Extensions/CUDA.kext
    • sudo rm -rf /Library/Frameworks/CUDA.framework
    • sudo rm -rf /Library/LaunchAgents/com.nvidia.CUDASoftwareUpdate.plist
    • sudo rm -rf /System/Library/StartupItems/CUDA
    • sudo rm -rf /usr/local/cuda
  3. Go to Apple > System Preferences

  4. Right-click on the CUDA preference pane
  5. Select the Remove "CUDA" preference pane option

OPTIONAL: If you also have NVIDIA Web Drivers installed (that's a 'yes' if you have the NVIDIA icon in the menu bar), then follow these additional steps:

  1. Still in System Preferences, click the NVIDIA Driver Manager preference pane
  2. Select the Graphics Drivers tab
  3. Click on the padlock and type your password
  4. Click the Open Uninstaller button
  5. Click Uninstall
  6. Complete the Uninstall process and restart your iMac