A timeout timer that starts after activating the relay and 10 seconds later calls a function that cancels the relay is what you need.
https://playground.arduino.cc/Code/SimpleTimer#F_setTimeout