they took what was almost certainly a profitable service and abandoned it
They oftentimes make a decision like this when their internal math tells them that the resources they put into domains could make them more money if they were put in another product. If you consider the opportunity cost, it could make sense to Google to make a change like this.
From our perspective, it's crazy, but it's easy to forget the huge scale of the money they are dealing with.
services like Gmail and Maps which can't be profitable
They aren't profitable, neither is Photos, but they are considered essential applications that keep users bought into the google ecosystem and are necessary for android to remain competitive.
But what percentage of their userbase wants to use them for domains. I'm sure it was profitable, but I doubt they were making as much on that as they could elsewhere. A service making them $50 million a year might not be enough for them to decide to continue with it when they are regularly dealing with products that make hundreds of millions or even billions from. It might just not be worth the effort.