If the action is dismissed for any reason, and the defendant has vacated the property under an order of possession or in reasonable contemplation of its taking by the plaintiff, the circuit court, upon demand of the defendant, shall order the plaintiff to (1) deliver possession of the property to the defendant or other person entitled thereto, and (2) pay damages to the defendant as justice requires, including damages for any injury to or impairment of the value of the property not within the reasonable control of the defendant.
Ala. Code § 18-1A-233 (1975)