As a rule of thumb, if you wait long enough (usually around 48 hours) your transaction will drop from all of the Bitcoin mempools and the funds will be returned to your wallet.
However, here are some other things you can do to expedite transaction confirmation:
Use Replace By Fee (RBF) – Some wallets (e.g. Electrum) will allow you to replace an existing transaction with a new one with a higher fee.
Use transaction accelerators – Some mining pools supply a service of accelerating specific transactions for a fee or on a first come first serve basis.