It's a scenario every manager dreads. You've hired a team. You like them. You know they're working hard and doing the best job they can. But they just can't do the job and you have to let them go.

Last January, Pat Sullivan faced that nightmare situation on steroids. Sullivan, a two-time successful entrepreneur had started his third company, Contatta, a customer relationship management (CRM) and collaboration platform that smoothly integrated with email. Potential customers were eager to use it, and he hired developers to build it.

The product they completed looked great. But when he tried it out, Sullivan became concerned. "It was beautiful, and it was built as a modern web application, but when you went from one module to the next it took a little too long for the screens to display. Having done this before and built two very successful products, you know when something's going to be acceptable and when it's not. And this was definitely borderline."

It was only going to get worse, he realized, when the system went live and started adding thousands of users. And so, after about a week of agonizing, he and his partners made the painful decision to scrap the product's back end and start over from scratch.

"It set us back more than a year and a half," he says. "If I were to put a number on it, I'd say we wasted about $3 million." His investors weren't happy. On the other hand, they were experienced enough to know that a reset of this kind is not rare in the world of tech start-ups.

The most wrenching part for Sullivan was firing five of the developers who worked on the original software. "These were good people, people that I liked," he says. They amounted to nearly half the staff of his small start-up. But he knew that the company needed different talent to build a successful product.

Here's his advice for any manager forced to fire a hard-working employee:

1. Admit you made a mistake.

"The most important thing for an entrepreneur is to be flexible and able to admit it when you're wrong," Sullivan says. That's never more important than when you've hired the wrong person for a job.

2. Don't delay.

Once you know you've made the wrong hire, the time to fix it is right away. You may be tempted to wait and see how things play themselves out, or hope that an employee who isn't up to the job will learn the skills he or she needs.

While it's good to give people a second chance, keeping the wrong hire can drag your whole company down. "It's probably the most difficult thing a leader has to do," Sullivan says. "But it was necessary if the company was going to have a chance to succeed."

3. Ask yourself why.

Why is this employee failing at this job? Is it because the person isn't trying? Is he or she distracted by personal issues? Doesn't understand the job or lacks needed skills?

It would have been different, Sullivan says, if his development team had failed because they weren't trying their best. "But the team I had worked really hard," he says. "There was no bad intent."

4. Apologize.

"It's really hard to soften the blow," Sullivan says. In some cases, he says, failing employees recognize for themselves that they're lacking knowledge or abilities to do the job well. "All you can do is say 'I'm sorry,'" Sullivan says.

So make sure you say it. And assure fired employees that you appreciate their contributions and work, and that whatever went wrong was not their fault.

5. Take responsibility.

"At the end of the day, the CEO is responsible for everything that happened, good and bad," Sullivan says. "Good stuff you want to dole out to other people, but blame--a CEO has to take the blame."

That's fine in the abstract, but in this case you also have to specifically take the blame for a bad hire. After all, it was indeed your mistake and no one else's to put someone in a job that didn't fit. "I hold myself responsible for not recognizing earlier that our product wasn't good enough," he says.

6. Look for chances to reassign rather than fire.

Sullivan was able to do this with one of his product's original developers who moved over to work on the company's website instead. It turned out she was very skilled at website work and that this was a good solution for everyone.

7. Be as generous as you can.

Hiring and then firing someone may mean causing that person financial hardship. So be as generous as possible with severance pay and such perks as health insurance. Sullivan believes this is especially important to do for employees who have tried their best, such as those who worked on the original Contatta. So he did what he could, allowing them to retain their stock options, for instance.

8. Help them find other jobs.

If employees have done their best, Sullivan says, "You do everything you possibly can to help them. Give them great references. Introduce them to other possible employers."

In Contatta's case, the story had a happy ending for the fired developers. "In each case, they landed somewhere that was better for them, doing something they're really good at," Sullivan says.

9. Now make the right hire.

Sullivan interviewed a developer he'd known from a previous company. He learned that developer was part of a close-knit team working at a large company. The team enjoyed working together but had lost interest in their current projects. They'd been discussing leaving together to start a new venture of their own.

Sullivan persuaded the entire team, including their supervisor, to come work at Contatta instead. And when they unveiled the newly redesigned product, he knew he'd made the right choice. The once borderline-too-slow application now worked so fast that users had trouble believing it was running in the cloud.

Because of the restart, Contatta's launch was badly delayed and at this writing, it has only been live for two weeks. Even so, several hundred businesses are already customers, Sullivan reports. "We've acquired many raving fans."