Model the water heater as a continuously stirred tank reactor (CSTR), so it is always at a uniform temperature. Assume the recovery time is not dependent on temperature and completely accounts for insulation losses and the like. Neglect losses in pipes and assume the operator controls the shower temperature to 105°F perfectly. Taking the stopping criterion from the question, the shower is over when the water in the tank becomes 105°F.
The recovery rate raises 140 gallons of water by 81.3°F in one hour. We'll say this is a constant heat input of 9118 W.
The key is that a constant-temperature shower removes a constant rate of heat from the tank, that which is associated with raising 2.5 gpm of water from 58.7°F to 105°F. This is 16986.5 W.
The difference is 7868.5 W. With constant heat, you don't need any complicated integrals.
The time for the tank to drop from 140°F to 105°F is 1568 s or 26 minutes.
The (maybe counterintuitive) fact that the variable flow rate from the water heater does not influence the rate of heat removal from the water heater comes from the fact that the incoming cold water is the same temperature at the shower and at the water heater.
Note that, because does not appear in the expression for , is now a constant.