When Nintendo stops making money from them.
Pretty much. The Wii U lost Nintendo tens of millions of dollars, but that's very tame compared to most video game hardware. It's because Nintendo just about never sold the Wii U at a loss. If they did, it was a minor loss.
As long as Nintendo is making at least a few million a year from the Wii U eShop and its servers are cheap to keep up, it's worth it for them. I'm sure almost no one was buying things on the Wii Shop from about 2015 onward, but Nintendo still kept it open.
Lifetime Sales Predictions
Switch: 144 million (was 73, then 96, then 113 million, then 125 million)
PS5: 105 million Xbox Series S/X: 60 million
PS4: 120 mil (was 100 then 130 million, then 122 million) Xbox One: 51 mil (was 50 then 55 mil)
3DS: 75.5 mil (was 73, then 77 million)
"Let go your earthly tether, enter the void, empty and become wind." - Guru Laghima