How do I backup a WSL instance to a `*.vhdx` file?

Step 1

Find the name of your instance:

wsl -l -v

learn.microsoft.com/en-us/windows/wsl/basic-commands#list-installed-linux-distributions

Step 2

wsl --export --vhd <instance name> $(date '+%Y-%m-%d-%H-%M').vhdx

E.g.:

wsl --export --vhd Ubuntu-22.04 $(date '+%Y-%m-%d-%H-%M').vhdx

How do I fix «The process cannot access the file because it is being used by another process» / «Wsl/Service/0x80070020» on wsl --export --vhd?