As soon as it is not profitable. The original reason for XBL being shutdown for OG Xbox was supposedly due to the 100 player friend limit, which despite the shutdown never changed for Xbox 360. Only on Xbox One did we see a change.
Realistically, Halo 2 was the only OG Xbox game that I owned that had a reasonable population account, which if I recall hovered somewhere around 2k before shutoff (don't quote me on this). My other favourite games, which were also quite popular at the time (Splinter Cell CT and Ghost Recon 2) only managed around 100+ whereas they used to have a large player count. If the other popular games dwindled that much (not including Halo 2) then MS had every right to shut it down, even though we may not agree with it.
Xbox 360 sold a substantial amount more than the OG Xbox due to a variety of reasons, including the OG Xbox's production costs and Sony's mishaps that helped propel the Xbox 360 to great sales, as well as clever decisions by Microsoft. Despite the Xbox 360 finishing in 3rd place after leading the PS3 for the majority of the generation, it still sold 80m+ compared to the 23m or so that the OG Xbox did. Given it took 5 years for OG Xbox Live servers to be shutoff, the 360 servers should have a few years left.
Microsoft's goal appears to be creating one unified Xbox experience. With their push for Xbox 360 BC and the return of OG Xbox BC, it is likely they're going to try to make it so games are not lost just because you are on newer hardware. PC games do not usually die but are sustained by the communities, for example, Halo CE on PC still had around 2K+ players even after 343 took over. When Gamespy shutdown, which Halo PC ran off, Bungie stepped in and with a collaboration with the community, both Bungie and the fans helped to make one final patch for Halo PC and then Bungie took it upon themselves to keep the Halo CE servers up and running for us the community. This is just one Halo related PC example of the community maintaining a game, despite Halo PC being well over 14 years old at this point.
I would love to see the console market embrace a PC like community, where if a game is that beloved it will be maintained by the community but unfortunately outside of a few rare examples, the markets are different and most are just happy for the next best thing. Long story short, you shouldn't worry for a few years at least.