Not a lawyer, but I believe a court would consider that "self defense". The principle is sometimes extended to include defending others. Although I'm sure it would be very unusual to have a situation where self defense required killing an innocent. Pretty sure it would apply to torturing the terrorist though. IMO that's why legalizing torture isn't necessary. There's already implicit exceptions to the law that apply in various "Jack Bauer" scenarios. There's also something the courts call "criminal intent". You can't accidentally commit a crime. Don't believe you can be coerced into committing a crime either.