Call Transfering

Well I think I have read just about everything on the net about this and am still no clearer on what to do.
I have interfaced asterisks 16 lines to 16 SIP handsets.Each handset has its own uncontended fxo line.
Works great until transfers.The problem occurs when the sip handset transfers but when it hangups its fxo line is still bridged with the transfer.The sip handsets even though free to ring other Sip handsets cannot receive incoming calls.The soultion here is to flash the line and then hangup the line. The call bridging is then done in the other pbx.
So I could use *4 extension number # for these transfers but this wont work for SIP -SIP transfers.So would use # or *2 for these but I can tell the enduser to use different codes based on whether transfer is to sip or fxo.
Surely someone has encountered this scenorio before…is there a workaround?

Most people would not have a 1:1 allocation between SIP and FXO lines. Most people would use ISDN with DID in this case.

i misunderstood how the fxo flash worked …all transfers are handled by the legacy pbx when flashed.