You can only cancel a pending transaction if it has not yet been added to a block. This can be confirmed by copying and pasting the transaction ID into its respective block explorer here:
If the transaction has at least 1 confirmation in the block explorer, it has already been added to a block and cannot be cancelled or expedited.
The process for cancelling or speeding up are very similar; there may be subtle differences depending on which wallet you are using. Here are instructions for several of most common types of wallets:
If you have sent a long queue of multiple transactions, you may want to cancel or speed up the very first of them to avoid congestion. Once the first one completes or is cancelled, the rest will be able to finish the confirmation process.