Some tasks take too long for us to want to wait around for them to finish. dd and sync are good examples:

$ sudo dd if=/dev/zero of=/dev/sdd bs=512 status=progress; sync

Instead, we can schedule a shutdown for when the process is found to no longer be running.

$ while [[ $(pgrep -x dd) || $(pgrep -x sync) ]]; \
    do sleep 300; \
done && \
sudo shutdown now

(While dd or sync are found to be running, wait for 5 minutes (300 seconds), then check again. When neither are running, shut down.)