If the right of a plaintiff in ejectment expires or the plaintiff's title terminates after the commencement of the action, but before trial, the verdict, if tried by a jury, shall be returned according to the fact, and judgment shall be entered that the plaintiff recover his or her damages by reason of the withholding of the premises, by the defendant, to be assessed, and that as to the premises claimed, the action shall be dismissed; and such damages may be thereupon assessed by the court or jury trying the case.
735 ILCS 5/6-127