This on a 2017 Retina 21" iMac Running MacOS 12.5
I am not looking for a solution to the kernel panic problem. I've given up on that. You can read about it here: How To Diagnose Too Many Kernel Panics....
Often, but not always, after a kernel panic there is no menu bar, no response to the keyboard, and no response to mouse clicks. The mouse does move the pointer around the screen. The keyboard is a Logitech K120 USB wired keyboard. I have tried four different "mice": An Apple Magic Trackpad, an Apple Magic Mouse, a simple Logitech wired mouse and a Logitech bluetooth mouse. All give the same sort of post-panic response.
Sometimes, and this is rare, the keyboard and mouse will suddenly become responsive. Then, if I enter the following into the command line:
sudo killall -KILL WindowServer
The menu bar comes back and I can use the Mac as usual.
If the keyboard does not become responsive, the only out is to reboot the Mac with the power button.
Any ideas as to what's going on here?