Yes, it is possible to exit a trade after a particular time period. You can code the same in your strategy logic in a platform of your choice ( Amibroker, Tradingview, MT4).
For example - A logic can be defined to exit after the 'n' number of candles.
A slight variation of the above is followed in Donchian Channel Strategy where if the candle closes below low of the past "n" candles, it sends Long Exit and Short Entry.
TradingView Algo Trading - Complete FAQs - MyCoder37
Let us know if you have any doubts.