Take Tumblr for example - they sold to Yahoo. Verizon bought Yahoo. If I was an engineer at Tumblr I'd be pissed that an evil monopoly like Verizon that's fighting against net neutrality is suddenly using my code.
I'm more humble now than I was in my 20s, and I don't think my code is anything special, but I still fear that the private company I work for will sell everything I built to someone I consider evil. If I have no control and no equity I'm going to act like a mercenary... I'll do the job efficiently and according to specifications, but they don't get anything extra. If they have an idea and have me build something that gets them rich that's great - but I'm not going to be like the guy who built GMail on the side at Google... I just do the job they tell me.
So what I am saying is at this point, do not worry about all these things. Keep up the side-projects, and if you do that over the long-term, you may one day find yourself in a situation where you have the freedom to dedicate your efforts to what you find meaningful.
But wouldn't you be happy that all your fellow coworkers also probably got to benefit from the sale? If you or your coworkers got rich enough then you could all just focus on doing things that you think matter or better the world!