I never use Caps Lock, so I disable the Caps Lock key completely with xmodmap, to avoid hitting it by accident.

Occasionally my X server gets into caps-lock state anyway. (Usually some complicated stunt was involved, like attaching x11vnc to the display remotely.) And then I can't turn it off again using the Caps Lock key.

So I wrote a tiny X client that lets me type 'xcapslock off' at a shell prompt …

… and then I had to make an alias to it, called 'XCAPSLOCK OFF'.

@simontatham I was going to suggest the built-in xkbmap option to turn LShift+RShift into Caps for such situations (as I usually run with -option compose:caps, it goes well with -option shift:both_capslock)...

Something else, vaguely similar, used to happen for me when I was doing nested RDP connections from Linux – FreeRDP into a VM host, then console into a VM – the X server would sometimes get stuck thinking a nonexistent /Shift/ key was pressed, just from watching a VM boot. What really made it weird is that it wasn't in Caps mode, as even holding physical Shift wouldn't return to lowercase (as normally would with Caps + Shift); it was as if I had a third Shift key stuck.

I could never figure out any any way to undo that, short of restarting the entire X server. Perhaps fortunately, Xwayland seems to be more resilient to that (and less impactful to restart anyway).