Installing an Nvidia driver on 20.04 Ubuntu interferes with orderly shutdown

Installing Nvidia driver 465.19.01 from Cuda 11.3 interferes with MDADM stopping a RAID10 array
during a regular shutdown. I have tried it with two kernels. If I install the drivers, MDADM will be unable to stop the RAID10 mounted on /. If I delete the driver, the shutdown proceeds cleanly to power off.

My guess is that the driver is still active in some way and is using the / file system. It is even true when I use rmmod to remove nvidia modules.

It is kind of ridiculous that I have had to track down this insane problem. I also spent a huge amount of time on trying to prevent Nvidia drivers from changing the mode on the built-in VGA and giving me black screens.

/etc/systemd/system/cleanup-nvidia.service
file, with the below content, would cleanly fix the issue.
#----------------------------------------------------------
[Unit]
Description=clean up nvidia modules
DefaultDependencies=no
After=shutdown.target
Before=final.target

[Service]
Type=oneshot
ExecStart=/sbin/modprobe -r nvidia_modeset nvidia_uvm nvidia

[Install]
WantedBy=final.target
#--------------------------------------------------------------------

Note the Before and After clauses.

Enable the Cleanup service with
sudo systemctl enable cleanup-nvidia.service