One example that comes to mind is Miller Puckette, who wrote Max, and then a few years later wrote its main open-source competitor, Pure Data. It seems quite possible to write a clone of your own software without literally writing the same thing, especially if it's been a few years and you have some new ideas about how to do it now. My guess is that doing so would most often be sunk, if it is, by software patents or explicit clauses in the sale terms, rather than copyright.
Quite often part of the purchase agreement is that you won't build a competitor to X for a certain number of years. Sometimes they go as far as not competing with the acquirer at all for that duration.
And if you use code that was included as part of the purchase, you're playing with fire.
What good is the domain without the code? They could rewrite the code from scratch. Though, that maks me wonder... If I single handedly write a piece of SW that does "X" and sell it to Yahoo. Can I then make a new site / app that dose "X"? Is it copyright infringement (a la the android / oracle Tim Sort) since anything I write that is an identical app is likely to have very similar, if not identical, code?
How much of what is in my head is mine and how much is covered by copyright if I've written it before?