Qubes-Whonix:
https://www.qubes-os.org/doc/yubi-key/#locking-the-screen-when-yubikey-is-removed
Lock screen is not as secure as it could be. Cold instant poweroff would be better. I.e. not "sudo poweroff" because Qubes sometimes has bugs preventing clean shutdown (it might wait forever). So better to just use some kernel command to cold poweroff.
Idea not sure it will lead somewhere:
echo b > /proc/sysrq-trigger
Non-Qubes-Whonix:
TODO