Regrets, bosses have a few.

Almost three out of four employers (74%) say they’ve hired the wrong worker for a job, according to a new CareerBuilder survey, while each bad hire cost companies $14,900 on average in the last year. Bad-hire burdens cited by employers included decreased productivity, compromised work quality and lost time for finding and training another employee, according to the Harris Poll of 2,257 HR and hiring managers.

Say you’ve soured on your latest hire. How long should you give the person to rectify the situation, and can you help him or her get better? How do you avoid this predicament in the first place?

“If somebody is not performing within the first 30 to 45 days, get rid of them,” workplace expert Stephen Viscusi told Moneyish, referring to a seasoned professional with five-plus years of industry experience rather than an entry-level worker. “You’re not going to like that person a year from now any more than you like them now.” If the chemistry is good and you’re willing to invest time, “maybe give yourself 90 days.”

Employers make bad hires because they’re desperate to fill a position or get fooled by an outstanding job interview, Viscusi said. But ultimately, he said, keeping that person is like being trapped in a bad marriage. “The longer it lingers, the harder it is to get out of.”

Inspire HR founder Jaime Klein agreed it’s important to swiftly address a bad-fit situation. “Within three months, you should start to see evidence that the person is quickly picking up on skills, or not. That they’re quickly picking up on the culture, or not.” A culture clash might be greater cause for concern, Klein said: “If someone’s smart and motivated, they can learn the skills.” Give senior employees more adjustment time, she added.

Also read: What to do if you’re struggling at your new job

Career coach Rebecca “Kiki” Weingarten was more lenient, barring any “egregious” conduct — suggesting leeway of six months to a year, especially if you don’t want the person to head to a competitor, you’ve heard good things or you admire the person’s body of work.

In the meantime, she said, talk about your expectations, your preferred management style and how you can help him or her succeed — whether it’s through extra training or team-building exercises. Provide specific examples of how you and the team view his or her performance, Klein added.

If there’s progress after you regroup, Klein said, great. If not, check in with HR, which may suggest a performance improvement plan to get the employee back on track by a certain date. Be sure to document the person’s poor performance to create a paper trail, she added. “We live in a litigious world, and we live in a social media world — people are going to be out there talking about what happened to them,” Weingarten said. “Cover your back.”

Also read: How to disagree with your boss without getting fired

Steer clear of the headache altogether by having “a lengthy and pretty intense interviewing process” that includes meeting various teams and key players, said Weingarten. And invest time and effort in onboarding, added Klein: “When we don’t train and mentor and coach people for those first 90 days, that’s when their less-stellar self comes out.”

This article was updated Dec. 7, 2017, to include findings from a newly released CareerBuilder survey.