The gemara says that if one calls his friend and he ignores him, he can throw a wall down on him - rashi explains that this is clearly not literal, rather if one gives mussar and the person fails to receive it, don't bother to continue, rather let him suffer the fate of his aveiros. This peshat seems difficult in light of the gemara in baba metziah that says that "הוכח תוכיח" requires a person to give mussar many times, even if ignored the first time.
The Rosh explains this gemara differently - If one has a claim on someone else and the person refuses to go to a din torah, he can bring hi to a secular court to take from him what he rightfully deserves.
Throwing dirt in the well:
The gemara says that a well that one drank water from he should not throw dirt into. Rashi explains that anything that a person once used, he should not degrade. This implies that even though he no longer has a use for the item, he should have a certain level of hakaras hatov for the item, not to degrade it.
The Shita Mikubetzes writes that we find this concept by the miracles in mitzrayim that were performed by Ahron, so that Moshe would not have to be kofer tov against that sea and ground that protected him. He tells a story of the Rif once getting sick and the neighbor allowed him to use his bath house to recover from his illness. After some time the neighbor went into debt and was forced to sell his bath house to bay his debts. The Ri"f refused to sit on the din torah to force the sale of the bath house since he benefited from it. He writes:
ואם היה זה בדומם שאין לו הרגשה כל שכן וק"ו בני אדם המרגישים בהיזק ובתועלת שיהיה זה שנוי לעשותו והעושהו יוצא משורת המוסר ודרך ארץ וכו' ואם היה זה במי שקבל הנאה מבשר ודם כ"ש וק"ו באלוה יתברך שממנו נשפע הטוב הגמור שראוי להודות לו הודאה גמורה ולא יעשה מה שיקניטנו ולא מה שהוא שנוי לו
Ultimately, this concept is a mussar for how to show hakaras hatov to people and how to show hakaras hatov to Hashem.