You could set a trap:
#!/bin/bash
export bunion_uds_file="$bunion_socks/$(uuidgen).sock"
trap 'rm -f "$bunion_uds_file"' EXIT
"$cmd" "$@" | bunion
This would make the `rm -f` command run whenever the shell session terminates, except for when terminating by the `KILL` signal.
As mosvy points out in comments, if this is a socket that needs to be cleaned up before use, it would be easier to remove it before recreating and using it:
#!/bin/bash
export bunion_uds_file="$bunion_socks/$(uuidgen).sock"
rm -f "$bunion_uds_file" || exit 1
"$cmd" "$@" | bunion