I’ve never done that but I think it should be easy enough with an automation. you could either use a timer entity and start the timer with the desired time duration and turn off the fan when the timer is finished.
Or you could do it with a delay in the automation but I think that needs to be hard coded into the automation. So option one would be better.
You could set the timer duration with an input datetime, input number or input slider. for the input number or input slider you will need two - one for hours and one for minutes since minutes can’t be more than 59 (I think…).