You can close a bank account with pending transactions. But after the account is closed, any incoming transactions will be declined by your (old) bank.
The best way to ensure this doesn’t occur is to either wait to close your account until all pending transactions are complete, or contact the creditor and supply them with alternate bank details.
If you’re unsure whether you have any scheduled transactions, you can speak to a banking representative over the phone or via online support.
In most cases, your bank withholds the amount owing for pending transactions (such as online purchases).
Because the pending amount is deducted from your bank balance, you can close your bank account and the purchase will be honoured.