No? Normally when you write the code, you get the code. This is true for other activities too: You write a song, in the end you get the song, make a painting, in the end, get a painting.
The fanbase and the money are all incidental, and sometimes orthogonal. You could write code that $makes some rich guy richer$ and that will probably make you more money than code that $gets a beer for everyone$, which instead might make you more popular. You could also write code to solve $a very specific problem that only you and 10 other people in the world have$, which will make you neither rich nor popular, but solves the problem that you had, so how valuable that code is all depends on the problem you had. Maybe you write some code that runs your insulin pump, so it keeps you alive without thinking about it. What's that worth? Is it more or less than the $makes some rich guy richer$ code? You decide.
What's even better is that in all of those cases, you still have the code. Even if someone makes a copy of it, even if you give it away, you still get to keep what you wrote. Isn't that fantastic? I think that's fantastic.
I get it. Making money is extremely important to you. Have at it. The world is your oyster. Some people have just moved past that point, which might be tough to accept, but is true, and I think they're on to something there.