I adopt the mentality that everything I do is a calculated bet. Many of those bets don't pay off, but the ones that do allow me to make more bets. As long as I'm proud of the things I've created in the end, that's enough to keep me motivated.
Still, a string of "bad bets" can be disconcerting - and I've had a few lately. But as long as we learn from our mistakes and are proud of our creations and accomplishments, that can keep us going.
It's also helpful to be realistic about what the worst-case scenario is, to keep the impact of failure in perspective. If your Udemy income suddenly dried up overnight (which is highly unlikely,) what would really happen? For most of us, we'd just go back to a "day job" or refocus on the one we have, and adjust our lifestyle accordingly. Not the end of the world. It's OK to take risks.
For any given project, like creating a course, there can be obstacles as well. What motivates me is the knowledge that the effort spent creating that course has absolutely zero value until that course is released. Quitting means losing all the effort you've put into it thusfar, and nobody wants that!