As luckyeight says - it all depends on the contract.
Most contracts will tie a band in for so many albums that it exceeds the life expectancy of the band itself - and hence any post-split 'Greatest Hits' or even a subsequent 'revival' - the profits will still go into the pockets of the record company.
Without researching it properly - I have a vague recollection that because ABBA were "only a Eurovision" band - their contract tie-in was rather short - hence they were able to re-negotiate more favourable terms due to their success.
Most newly signed bands find out to their cost, that when, fresh from their sweaty pub gig, the Limo picks them up to sign the big Record Company contract (with Champagne on tap)- then the cost of it comes out of their eventual profits.