Yes, trades can be closed before expiry.
Just select the “SELL” button next to the trade you wish to close to receive a quote. If you agree to this quote, your trade will be closed and funds returned to your account.
You are able to close trades up until the no trading window (typically 1-5 minutes) before the option expiry.
This no trading time varies for different asset types:
Forex: 2 minutes
Commodities: 2 minutes
Stock Indices: 5 minutes
Stocks: 5 minutes
Cryptocurrencies: 5 minutes