Try pfctl -F all -i {$interface_that_goes_down}
Is better and should avoid running it twice.
Using
#!/bin/sh
sleep 5
/sbin/pfctl -F all
causes no new states created- Diagnostics: Show States- "No states were found."
back to
#!/bin/sh
sleep 60
/sbin/pfctl -F state
sleep 40
/sbin/pfctl -F state
This also makes when WAN or OPT1 are back online, all connections to use their preferred gateway again, which is good.
If we reset states on the failed gateway only, the above will not happen.
Need more time to study the negative effect of reseting states.