The world of credit cards is full of paradoxes, and taking an action that you might think would boost your credit score can actually end up hurting it. One of the most confusing ways that you can accidentally make your credit take a major hit is by closing your accounts. Here is a look at how your individual credit cards impact your credit score, which should help you figure out when closing an account is actually a good idea.

How Your Credit Score Is Calculated

It’s important to realize how your credit score is calculated and what sorts of actions on your part can help or hurt. Your FICO score (which is the one most lenders will look at when determining whether you qualify for a loan) takes several different factors into account, such as your payment history, the amount you currently owe, the length of your credit history, and the types of credit that you use. While your payment history has the biggest impact on your credit rating, the amount your owe makes up 30 percent of your FICO score and the length of credit history is responsible for another 15 percent.

Impact of the Debt-to-Credit Ratio

Now that you have a basic idea how your credit score is calculated, you can start to think about how closing an account might end up being bad for your overall credit. The way that FICO (and the major credit reporting agencies like Experian, Equifax, and Transunion) figures out the portion of your score related to your credit usage is by calculating your credit utilization ratio, which is also known as your debt-to-credit ratio.

Say you have four credit cards, each with a credit limit of $5,000. The total amount of available credit in your name would then be $20,000. In general, you want to keep your debt-to-credit ratio below 25 percent at all times, which means that you wouldn’t want the total combined balance of all four credit cards to exceed $5,000. Now, imagine that you have paid off the balance of three of your four credit cards and decide to cancel them. Suddenly, your amount of available credit will drop from $20,000 down to just $5,000. While you may be used to spending up to $5,000 on your credit cards without it having a negative impact on your score, you can’t keep charging that much without it looking like you are maxing out your remaining card.

While a simplified example, this situation often hurts consumers’ credit unexpectedly. You might think that it’s a great idea to close an account once your debt is paid off, but a spike in your credit utilization ratio can cause your overall score to take a major hit. In general, you should never cancel your card with the highest credit limit, even if you don’t plan to use it anymore. Just put the card away and make occasional charges to keep the account active, and you will find that it’s easy to keep your debt-to-credit ratio low.

Closing Your Oldest Account

Remember the credit card you applied for when you had just turned 18? Since you probably didn’t have much of a credit history at that point, the terms and conditions for that card probably weren’t great. Years later, you may be tempted to cancel that card–especially if you never use it anymore. Before calling the bank, however, you need to think about how this decision will impact your credit score.

Remember that 15 percent of your score depends on the total length of your credit history. If your first credit card was also your only credit card for a number of years, then canceling it will shorten your credit history by a substantial amount. As a general rule, you should try to never close your oldest account (especially if it doesn’t have an annual fee to keep it open). Instead, just use the card once every few months and keep it tucked away in a drawer.

The Bottom Line

Occasionally, there will be circumstances in which it is a good idea for you to close one of your credit card accounts, but you should never come to the decision without thinking through the potential consequences. As long as you aren’t abusing your credit, the best action you can take is often to keep your old accounts open and allow them to help your score without you needing to do any work.