Your work visa could be rescinded at any point, yes. But if you're eligible to immigrate, the earlier you start, the earlier you get to a permanent status, right?
Also, even if your visa is rescinded on short notice, and you must leave immediately, you would likely earn more abroad than you can in your home country, right? What you've earned and not spent can likely help your future at home... Maybe it's enough to start a company at home where you can use your STEM skills. The experience you've gotten and the network you've built might possibly enable working remotely.
All that said, STEM fields vary widely. Many fields need tremendous capital to do 'great things', computer science does for some things, but not for others.