The court may refuse to render or enter a declaratory judgment or decree if such judgment or decree, if rendered or entered, would not terminate the uncertainty or controversy giving rise to the proceeding. However, the court shall render or enter a declaratory judgment or decree in an action brought by or against an insurance company to determine liability of the insurance company to the insured to defend, or duty to defend, although the insured’s liability for the loss may not have been determined.