When stocks are volatile, conventional wisdom says to stay the course. But what if you have tuition due or a pending home purchase and you just really need to cash out?

If you need the cash now, while stocks are likely to be on a wild ride, here are some things to consider:

Plan ahead, even a little bit

Ideally, if you have a big, scheduled payment coming up, you would plan ahead and move money from stocks to a high-yield money market account or other safer investments. “The longer runway you have, the safer you will be when you have to take the money out,” said Corbin Blackwell, a certified financial planner with Betterment, an online wealth management firm.

Eighteen months to a year is ideal, but sometimes that can stretch longer. Financial planner Erika Safran, who has her own firm in New York, has clients who have kept cash sitting two and a half years now, waiting to find their dream home.

Even a few weeks can do the trick. If you are facing a situation like tuition due on Aug. 15, you could sell a third of the shares you need 10 days prior, then another third a few days after that and the remainder a few days before the deadline, said JJ Kinahan, chief market strategist at TD Ameritrade.

You can also make decisions based on the balance you need, Kinahan said. If tuition is $30,000, sell shares for half the amount a few months before, and then set high and low limits for selling the rest.

Choose carefully what to sell

Not all stocks in your investment portfolio are the same, so when you go to sell, do research. Portfolio manager Jenny Van Leeuwen Harrington spoke to a client this week who is raising cash. The client had three buckets to choose from with different tax implications.

For the most part, if you want to minimize capital gains, sell the stock with the least embedded growth.

When it comes to exchange-traded funds, your holdings might have a different cost basis if you bought shares over time. “You need to call and say ‘I want to sell my highest-cost position so I can minimize taxes,’ ” Harrington said.

Consider selling bonds at the moment instead of stocks, said Bill Northey, senior investment director for U.S. Bank Wealth Management. For that matter, look at alternatives like a home-equity loan or portfolio line of credit to avoid selling altogether, Northey added.

Be at peace

Even with last week’s volatility, stocks were still up nicely for the year, so it is not actually such an inopportune time to sell.