Either article is grammatically correct. Which one is used depends on the situation. If there is only one hanger in the closet, then "the" would be used. If there are multiple hangers, then "a" should be used.