in a hostage crises is it ethical for a government to agree to grant a terrorist immunity if he releases the hostages

In a hostage crises, is it ethical for a government to agree to grant a terrorist immunity if he releases the hostages, even though the government has every intention of capturing and prosecuting the terrorist once his hostages are released?