The receipt of money tendered before an action is commenced is a bar to the action and, if after an action is commenced, such releases the defendant from all damages and costs, except the costs which accrued before the tender and receipt of the money.