Mwan3 not reverting back to main wan

You would want to create a second wg_iface with a different source port.

Unfortunately, you will need to create some custom firewall rules, because mwan3 won't handle rules for ip addresses that have a static route, which is added by the wireguard script.

You could add something like this to your /etc/firewall.user (warning, untested code)

. /lib/
. /lib/mwan3/
. /lib/mwan3/
config_load mwan3

function wireguard_ipt_rule ()
  local id interface endpoint sport
  mwan3_get_iface_id id "$interface"

  $IPT4 -I OUTPUT -d "$endpoint" -p udp --sport "$sport" \
        -j MARK --set-xmark "$(mwan3_id2mask id MMX_MASK)/$MMX_MASK"
wireguard_ipt_rule wan 185.XXX.XXX.XXX 51820
wireguard_ipt_rule wwan 185.XXX.XXX.XXX 51821