The idea of holding on to a stock through thick and thin for decades is scary. What if something goes wrong? What if it underperforms, or goes belly-up altogether? Yes, it's worrisome, but finding top-quality companies and holding their shares for years, if not decades, should be the goal and not the exception for investors.

So, what are some stocks that you can feel safe about holding for decades? We asked three of our Foolish investors to think long term, and they identified International Business Machines (IBM 0.18%)Alphabet (GOOG 1.43%) (GOOGL 1.42%), and Berkshire Hathaway (BRK.A 0.99%) (BRK.B 0.91%) as three of their top choices. Here's why.

A woman holds a fan of $100 bills.

Holding on to these top-quality stocks for the long term can help your portfolio outperform. Image source: Getty Images.

A transforming tech giant

Tim Green (International Business Machines): IBM has been around for over a century. The company is currently going through a transformation effort, attempting to shed its image as a tech dinosaur by betting on newer technologies like cloud computing, artificial intelligence, and blockchain. This isn't' the first time that IBM has transformed itself. The company faced an existential crisis in the 1990s, saved by an outsider CEO who recognized that IBM was worth more than the sum of its parts.

After five years of slumping revenue, IBM finally reported a year-over-year sales increase in the fourth quarter of 2017. The company also expects sales to rise in 2018, buoyed by a new mainframe system and double-digit growth in its key growth businesses. In 2017, IBM's "strategic imperative" growth businesses grew revenue by 11% to $36.5 billion, while the cloud computing business produced revenue of $17 billion, up 24%.

Overall revenue growth will almost certainly be slow, with the legacy portion of IBM's business dragging down the numbers. Buying and holding a slow-growing tech stock may not seem exciting, but IBM has a lot going for it. Its deep base of existing customers is a competitive advantage, allowing it to more easily sell hot technologies like blockchain and cloud computing. Case in point: The company signed a $1.7 billion 10-year cloud computing deal with Lloyds Banking Group last year, a long-standing IBM customer.

The IBM of 20 years from now will look different from the IBM of today, much like the IBM of today looks different from the IBM of 20 years ago. But it's the company's ability to adapt that makes IBM a stock worthy of holding for the long run.

Alphabet's a hold, not a buy

Rich Smith (Alphabet): I'm going to make a somewhat nuanced argument here, so bear with me: If you already own it, or if you get a chance to buy it at a good price in the future, I'd strongly recommend holding on to Alphabet stock for the next 20 years -- but I wouldn't necessarily buy more at today's price.

Allow me to explain.

One of my favorite companies to buy right now is SpaceX -- a company that, unfortunately, is private, so you cannot buy it directly. You can, however, buy a piece of SpaceX indirectly, by buying Alphabet, which purchased a 7.5% stake in SpaceX in 2015.

SpaceX is currently dominating the market for space launch in America, and even worldwide. This year, the company plans to launch more rockets than the rest of the world combined. And with its recent launch of the world's largest rocketship, and ambitious plans to begin testing an even larger rocket for interplanetary travel next year, SpaceX now constitutes a truly unique investment.

What's more, until such time as SpaceX decides to issue an IPO, buying Alphabet stock is the truly unique way to invest in SpaceX. For this reason, I would not sell Alphabet if you already own it, and I would buy more of it at the right price.

But I do have one reservation in making this recommendation: Currently, at a P/E ratio of more than 61 times earnings, and a growth rate of 20%, Alphabet stock is not cheap. My advice: Don't buy more of it until it becomes so.

Rolling with the punches

John Bromels (Berkshire Hathaway): One of the toughest things to account for when considering holding a stock long-term is a potential disruptive technology ruining the investment. For example, shareholders of typewriter companies probably thought their investments were secure forever -- we'll always need to send written communications! -- until word processors and PCs completely destroyed the industry. 

That's why the safest investment for the long term may be one that invests in a wide variety of companies and can adjust its portfolio if needed. So, for the next 20 years, Warren Buffett's Berkshire Hathaway looks like a sure bet to me.

Now, the first thing you might say is that the 87-year-old Warren Buffett is unlikely to himself be around for the next 20 years -- although I wouldn't put it past him. But the company's portfolio certainly will be, and a whole host of executives who grew up listening to Buffett's wisdom and know his thinking inside and out will be, too.

Meanwhile, the company's holdings in industries as diverse as insurance (GEICO), railroads (Burlington Northern Santa Fe), food (Dairy Queen, See's Candies), and more will help investors avoid a total loss when a problem develops in one or even more than one of those sectors. Additionally, Berkshire owns and actively manages stakes in many other corporations, so the company is about the safest opportunity I can think of for investors to buy in and forget about for decades.