What to do when a store going under refuses to take your gift cards

Retailers often stop honoring gift cards when they declare bankruptcy. But that's money they've been paid in advance, so can they really refuse your gift card?