UNITED STATES—Winning the lottery and losing it all—it’s hard to fathom but happens a lot more often than you might imagine. Some people have won millions of dollars and squandered it overnight. Others made thoughtless decisions that led them to jail or cost them their lives.

Sometimes it doesn’t have to be your fault. In 1996, Jeffrey Dampier Jr won $20 from the Illinois lottery. He then divorced his wife and re-married. Unfortunately, two of his new in-laws kidnapped and killed him in 2005.

Winning the lottery doesn’t have to end badly for you, though. You can win a life changing amount of money and avoid ruining your life. Here’s how.

 Remain Anonymous

Stories like that of Dampier Jr are why you should claim lotto winnings anonymously. You never know who’s planning to harm or exploit you. How do you claim your jackpot winnings anonymously? The best way is to set up a trust using a unique name.

Then you can register a Limited Liability Company (LLC) owned by the trust you just created. After that, hire a lawyer who acts as your LLC’s agent and have them sign your lottery ticket. Your lawyer can’t reveal your identity—attorney client privilege—and the LLC will help keep your lotto money privately.

Using trusts and LLCs is how a lot of wealthy people hide their wealth from friends and family. It’s probably also how the biggest lottery winner in Canada, who won $70 million and remained anonymous as reported here, claimed his or her winnings.

Erase your Digital Footprint

It’s true—you can’t eradicate 100% of your digital footprint. Someone who knows you might post photos you took together online. If you’ve ever been involved in a court case, there’s a chance the courts might have posted your name online too.

All the same, there are certain things you can do to reduce your digital footprint. Start by deleting your social media accounts, or at least remove sensitive information. The thing is, lottery winners attract a lot of attention from the media, bloggers and scammers.

People will come looking for your photos, addresses, names and everything else they can use to talk to you. Make it hard for people to reach you after you hit the jackpot by removing your addresses and contacts from your Facebook, Twitter and Instagram accounts.

Skip Town

Another way to protect yourself from the media and people trying to expose you after you win the jackpot is to skip town. Go away for a while even if you claimed the lottery anonymously. The explanation is that lotto organizations often required to state the province, city or town where their jackpot winner came from.

So, even though people might not know your exact name, they could have an idea of which town you live in. And in doing so, they could look out on who’s quitting their job, buying fancy cars or upgrading their homes. Skipping town helps reduce the interest in identifying lotto winners. And as a result, you can use your money afterwards with no one seeking to make you famous.

Don’t Spend your Money Immediately

Unless you have bills that must be paid immediately, avoid spending your lottery jackpot immediately after you win it. The reason is that you’re highly likely to misuse it now that you have more money than you’ve ever had.

Don’t even buy your parents and siblings sweet gifts, at least not for the first three to six months. Instead, take time to create a sound financial plan with the help of a professional. That means continue working if you love your job or quit but spend minimal amounts.

Your money won’t probably accrue a lot of interests for six months while in the money. But it’s better to keep your jackpot intact than to squander it by purchasing through excessive purchases. Speaking of which, involve your spouse in your decision. It can help keep your marriage even after you become rich.

Seek Financial Advice

As mentioned, the best way to spend a jackpot is with the help of a financial advisor. However, it also helps to become financially literate—the ability to manage money while keeping minimal debts and accruing profits through sound investments.

Over 70% of lottery winners lose their wealth in a few years according to NEFE. In many cases, that’s because the winners lacked financial literacy. They couldn’t handle the sudden windfall they received and it proved to be too much to manage.

According to wealth advisor Ronn Yaish, lottery winners should handle their money the way people handle emergencies—flooding, fire disasters or a toothache. You seek help immediately. Do the same with your jackpot—ask for help from a professional so that you can use it to make more money in the long term.

Hire a Lawyer

If you can’t remain anonymous after winning a jackpot, hire a lawyer. A good attorney can help you deal with the sudden emergence of litigations that target lottery winners. It could be your close family members, former spouses or friends.

A lawyer can help you navigate these issues without spending a lot of money in the process. They could also help you insure your property and assets from similar litigations. With that in mind, hire a lawyer with reasonable fees. You don’t want to spend a significant portion of your cash on attorney fees.

Live Within your Means

Living within your means is easier said than done when you suddenly have $50 million in your bank account. The first thought that comes to mind is to buy new stuff—a million-dollar home, a fancy car, new expensive clothes and new household items.

Although you’re allowed to buy all these things with your new found fortune, take time to determine what you can afford to buy without ruining your life. Invest a significant portion of the money and spend the rest wisely. If you have to make donations and buy gifts for people you love, also buy these things while minding your budget.