It can be hard to throw down the anchor at a new job — especially when you’re dying to jump ship.

Conventional wisdom follows the stay-at-least-a-year rule. Nationally, the median employee tenure for wage and salary workers in January 2016 was 4.2 years, a slight dip from 4.6 years two years earlier, according to the Bureau of Labor Statistics. Numbers trended higher for older employees: Median tenure was 2.8 years for workers aged 25 to 34 and 10.1 years for those aged 55 to 64.

But extenuating circumstances can push even the best-laid plans off course. In that case: How long do you have to stay at a new job, when is it OK to split after a few months, and how do you explain a brief tenure to your next employer?

Leadership expert Todd Dewett prescribes 18 to 24 months as a general minimum: “For most jobs, what that means is you’ve survived onboarding, you’ve ramped up a learning curve and you’ve very likely successfully passed your first evaluation,” he said. Career coach Karen Elizaga, meanwhile, pegs the minimum between a year and 18 months.

“There is some value in that year mark,” career coach Julie Cohen told Moneyish. “It enables a new employee to understand the culture of the organization, to get through the entire calendar year,” undergo performance reviews, forge a relationship with the boss and build internal relationships. With that said, no single benchmark holds true for everyone, Cohen said: Certain events can warrant rebooting the job search within three to six months.

One of executive coach Maggie Mistal’s clients “politely resigned” after just a week on the job, she told Moneyish in an email. Since the employee had been candid about the job possibly not being a good fit, given the job a try, and avoided wasting company resources on training, Mistal said, “the company was OK with it.” “You can leave at any time but you’ve got to make the best ending possible for you, your employer, coworkers, customers,” she said, “taking into account your needs as well as all those affected by your potential resignation.”

A premature exit is acceptable in the case of a major corporate scandal — think Enron — or performance issue expected to result in significant layoffs, Dewett said, as well as in the event you snag your dream job. You should “jump ship as soon as you can” if the organization’s goals are antithetical to your own values, added Elizaga. Other valid reasons include your physical or mental well-being at stake, an absence of opportunities to develop and grow, or an environment that could be detrimental to your career goals, Cohen said. You may also have chosen to leave or been counseled out because the boss, culture or demands of the job posed an obvious and significant bad fit, according to Dewett.

Inadequate excuses for splitting after just a few months include boredom, dislike of coworkers or an immediate emotional reaction to job duties, Cohen said. “You need to be able to address … ‘Is this situational and I need to just kind of learn the ropes, or is this systemic — this organization is not a fit and I’m not going to grow here’?

You may not even need to give a three- or four-week “blip” of a job resume real estate, Cohen said, especially if it was just a bad fit. “It’s almost like a no-fault divorce,” she said. “It was a mistake. Stuff happens.” (If an employer asks about a resume gap, she added, never lie.)

Once you’ve decided to leave early, get ready to “tell a story” around why — without trashing the boss or company. “You have to be able to explain what you’re moving towards,” Cohen said. “Not ‘I hated my boss’ or ‘This environment sucked’ — it’s ‘Moving to this position enables me to do XYZ.’” While there should be some acknowledgement of your brief tenure at the last gig, the ways in which the new job will allow you to use your skills and contribute should drive the focus.

“You have to sustain your brand that you’re still this valuable resource and a talented employee,” she said. “You don’t want the choice to define who you are as a professional, and you do that by building on what you can contribute and do.”