Sometimes the end is inevitable.
Learning to lose with grace in StarCraft 2 has it's benefits. There comes a certain point in each game where you know - without a doubt - that you will eventually lose. Your opponent may have a huge army that will crush yours in a heartbeat or they may have 7 bases when you still only have one. No matter what the situation, when you know that you have no hope of coming back it's time to surrender.
New players might not know this, but you don't have to completely finish out a game by waiting until all of your structures are destroyed. If you hit F10 (or click the menu button) one of the options within the menu is surrender. Usually when you're ready to throw in the towel it's good manners to say good game - typically abbreviated gg - to your opponent and then surrender.
That button, right there.
By surrendering instead of prolonging a game it lets both you and your opponent move on to the next game faster. Why hold on in a losing game? Instead, you can graciously bow out and start a new game with a blank slate where you might actually win. You'll get more games under your belt in a shorter amount of time and you won't draw out that crisis feeling that happens when playing a losing match.
Once you're not afraid to surrender losing loses some of it's sting. It frees you up to try new builds, random ideas, and creative tactics. It's much better to experiment and not fear a loss than it is to constantly do the same thing every single game and grow bored or frustrated. There is no "right" way to play StarCraft 2 and sometimes the most unorthodox strategies work wonderfully. Trust me when I say that creative strategies come from players that aren't scared of losing.