There are some plans which allow you to withdraw money for any reason, though they are rare.

Generally, most plans require that you use the money only for a "financial hardship." 

Many employers use the guidelines set forth by the Internal Revenue Service. According to the guidelines, the withdrawal must be due to "an immediate and heavy financial need" and the withdrawal must be necessary to satisfy that need. That really means that you would have had to have used all other options (including borrowing from your 401(k) before you get to this stage.

 IRS approved reasons:

Think twice before you take the money-

You’ve worked so hard to build up your retirement
account. Before yon take a financial hardship withdrawal, you should consider all other sources of money that may be available to you.

Finally, it’s a smart idea to check in with your financial adviser before requesting a hardship withdrawal. He or she can analyze the impact of a hardship withdrawal, taking into account your financial situation.  Plus, your adviser can help you explore other options that may be available to you.