Google's decision not to renew a contract to develop artificial intelligence for the Defense Department was a victory for the employees who had protested it. It was also a defeat for U.S. national security, patriotism, and the cause of limiting civilian casualties in war.

The program, officially named the Algorithmic Warfare Cross-Functional Team but known in the Pentagon as Project Maven, uses machine-learning software to interpret video images and could improve the accuracy of drone strikes, among other things. Last month, around a dozen Google employees quit their jobs and thousands of others signed an open letter demanding the company exit the program because it "stands in direct opposition to our core values."

But the program's software, which tags things like buildings or suspicious human activity on digital maps, is intended in large part to help the military avoid accidentally striking noncombatants and civilian infrastructure. It is also being expanded to other areas such as speeding up the reading of computer drives taken from terrorists.

The company understood all this as recently as April, saying in a statement that the technology "is intended to save lives and save people from having to do highly tedious work." Yet some bad public relations and a handful of people walking out is apparently all it took to provoke the reversal. One of the roles of senior management is to do the right thing, even if it provokes criticism. That's especially critical when our collective security is at stake. One can understand why some might be leery about a slippery slope to machines making life-and-death decisions without humans in the loop. But that's an argument for staying on the project, so they could influence future applications.

Google's leaders also seem to have forgotten the vital role the government, and especially the Pentagon's Defense Advanced Research Projects Agency, played in creating the internet and making their company possible in the first place. Yet, from Apple's refusal to unlock the iPhone of a mass-murdering terrorist to Project Maven, tech firms have repeatedly snubbed law-enforcement, intelligence and defense agencies.

Fortunately, some tech companies have deigned to help the U.S. defend itself. Amazon.com's cloud computing arm has collaborated with the intelligence community as well as the Pentagon, and is believed to be the front-runner for a (highly controversial) multibillion-dollar Department of Defense contract. But Google's decision may put pressure on other firms and their funders to shun the Pentagon in the future. Will Microsoft, IBM and others that Google reportedly beat out for the initial Maven contract, which expires in 2019, get back in the bidding for the next one?

Hopefully so. Helping to defend the U.S. is nothing to be ashamed of. That shouldn't be a controversial idea among our nation's business leaders.

Michael R. Bloomberg, the former mayor of New York City, is the founder and majority owner of Bloomberg LP, the parent company of Bloomberg News. He is the UN secretary-general's special envoy for climate action.