I gave a pretty comprehensive answer to this question three years ago. But it comes up all the time. In fact, cancelling a card just the other day the retention specialist (whose job it is to convince me not to cancel) threatened that I would lose my American Airlines miles if I canceled my co-brand credit card. That’s just wrong.
Under almost all circumstances you will not lose airline or hotel points earned through a credit card when you cancel the card. That includes both signup bonuses and points from spending on the card. However, if you close a bank’s proprietary rewards card, you’ll generally lose those accumulated points.