Thank you for reaching out about this. It can be understandably stressful when trying to find out the best way to refund a customer when their card has been closed by their bank.
I reached out to my Shopify Payments team to get some more insight into this matter and they informed me that in these cases you would still process the refund to the closed card and the customer’s bank should have processes in place to redirect that refund to the customer’s account. This would be considered an industry standard in most countries as many payment processors do not allow refunds to be made to cards/accounts that weren’t originally involved in the transaction.
If your customer paid through a gateway other then Shopify Payments it would also be worthwhile to reach out to that payment gateway to confirm their processes in these matters.
Let me know if you have any other questions about this situation, I’d be happy to help.