Why does VirtualBox crash macOS? I installed VirtualBox on my new Mac mini, running macOS Mojave, and it randomly crashes the computer (sometimes it does, other times it doesn't).

The last time it crashed such that both my monitors (that are plugged into the Mac mini through USB-C to HDMI adapters) were not working. I spent close to 2 hours trying to figure out what happened. I was sure it was something internal, and not the USB-C ports, because I was able to open recovery (by pressing and holding Command + R during boot) and see what's being displayed, but I wouldn't see anything when I'd normally turn on my computer.

After 2 hours of trying different things, I plugged one of my screens into HDMI (instead of USB-C) and saw the password screen, logged in, and the USB-C ports started working again.

Can someone explain what is going on here? I started to think that this was the computer trolling me. I never had these problems on either Windows or Linux.
This is commonly due to bugs in VirtualBox.

VirtualBox installs itself as a kernel extension directly into the lowest level of kernel software running on your Mac affecting stability of the system as a whole. This is why you need to enter an administrative user’s password in order to install VirtualBox.

To fix this, ensure that you have the latest software versions of VirtualBox, add-on packs and macOS installed. Double-check your virtual machine configuration for configuration errors (especially if you’re using PCIe pass-through or similar).

If this doesn’t solve your problem, I will advise using a different virtualization system such as VMware Fusion or Parallels Desktop.