Here are a few VirtualBox command line snippets I’ve collected.

Snippets

List running machines (returns name and UUID)

VBoxManage list runningvms

Stop a running VM by “hibernating” it

VBoxManage controlvm <name|uuid> savestate

Power off a running VM

VBoxManage controlvm <name|uuid> poweroff

Use ACPI in an ACPI-aware guest OS (graceful shutdown)

VBoxManage controlvm <name|uuid> acpipowerbutton

Start a VM in headles mode

VBoxManage startvm <name|uuid> --type headless

Scripts

Hibernate all currently running VMs

GNU Sed (Linux)

VBoxManage list runningvms | sed -r 's/.*\{(.*)\}/\1/' | xargs -L1 -I {} VBoxManage controlvm {} savestate

Sed (macOS)

VBoxManage list runningvms | sed -E 's/.*\{(.*)\}/\1/' | xargs -L1 -I {} VBoxManage controlvm {} savestate