It costs massive money to keep an aircraft production line open, and C-17 sales dried up in spite of Boeing's best efforts to drum up sales. The last 10 C-17s built were effectively 'white tails' without committed buyers - basically a couple billion dollar bet by Boeing that they could sell them.
Last I heard, a year after the line was shut down, there was still one brand spanking new C-17 unsold.
Madness would have been to spend billions to keep the line open without buyers.