As much as there’s an art to starting a successful business, there’s an art to quitting, as well. Founding a business is tough enough, but shutting it down can be even harder. For an entrepreneur who has poured their heart, soul, and savings into a fledgling business, the process has as much to do with letting go emotionally as with physically pulling the plug on operations.

If the business isn’t taking off, there can be a fine line between how soon is too soon, and how late is too late, to call it quits. Taking on personal risk to fund your venture and teetering on the brink of financial peril are not the same thing. As Kenny Rogers famously sang, “You got to know when to hold ‘em, know when to fold ‘em/know when to walk away and know when to run.” So how do you know?

Your initial business plan should always include a “runway.” If your business hasn’t taken off by the time you reach the end of the runway, you don’t keep driving. You can calculate the length of your runway by taking a close look at your burn rate: How much cash do you burn through in a month, and how long is that sustainable, given your savings? When I started Lexion Capital, my runway was three years. If Lexion had not been successful within that time frame, my plan had been to re-enter the corporate workforce.

Of course, there are always the by-the-skin-of-their-teeth success stories that become legend. What entrepreneur at the end of their rope wouldn’t hope for an eleventh-hour turnaround à la Fred Smith, the founder of FedEx, who, in FedEx’s early days, famously saved the company by hopping a plane to Vegas, gambling the last $5,000 on the blackjack table, and winning? Keep in mind, though, that the only consistent winner in a casino is the house. Gambling it all once you’re off the runway is never statistically a smart move.

The fact is, many initial ventures aren’t successful. That doesn’t mean your efforts have resulted in failure. The trick is to time it well so that you can cut your losses, take what you learned, and move forward.