We propose a class of sharing schemes for the distribution of the gains from cooperation for coalition games with externalities. In the context of the partition function, it is shown that any member of this class of sharing schemes leads to the same set of stable coalitions in the sense of d'Aspremont et al. (1983). These schemes are "almost ideal" in that they stabilize these coalitions which generate the highest global welfare among the set of "potentially stable coalitions". Our sharing scheme is particularly powerful for economic problems that are characterized by positive externalities from coalition formation and which therefore are likely to suffer from severe free-riding.