SPA-3000 outbound and IAX2 Trunks

I have 2 SPA-3000 setup for inbound and outbound calling. I also have an IAX2 trunk setup for outbound calls. I seem to be having a problem with outbound calls when the SPA-3000 is in use. The SPA-3000 is talking SIP back to Asterisk. Here is what I have on the extension rules for outbound. The rule is specific for only 212 calls.

exten => _91212NXXXXXX,1,ChanIsAvail(SIP/@pstn-6391)
exten => _91212NXXXXXX,2,Dial(SIP/${EXTEN:1}@pstn-6391,60,tr)
exten => _91212NXXXXXX,3,Hangup
exten => _91212NXXXXXX,4,Set(CALLERID(all)=${CALLERNAME} <${CALLERNUM}>)
exten => _91212NXXXXXX,5,Dial,IAX2/${EXTEN:1}
exten => _91212NXXXXXX,6,Dial,IAX2/${EXTEN:1}
exten => _91212NXXXXXX,7,Congestion

So when someone is using the SIP trunk to pstn-6391 the following error comes back.

Got SIP response 504 “Service Unavailable”

The system never goes to the next set of rules to go out via the IAX2 trunk. How can I get Asterisk if that error is received to go to the next option.