Юзай
Код:
hooksecurefunc("TradeFrame_OnShow",function()
  if UnitAffectingCombat("player") then
    CloseTrade()
  end
end)