General mechanism for the nucleophilic substitution:
Methanol can aid the process through acting like a base. The last stage in the mechanism is similar as before. The carbonyl π bond is again formed and since this occurs, the C-Cl σ bond breaks along with both electrons ending up on the departing chloride ion since a fourth lone pair of electrons. Lastly, the chloride anion can eliminate a proton from CH3OH2 to form HCl and methanol.
The above mechanism is necessarily the same mechanism included in the reaction of ethanoyl chloride along with sodium methoxide, the only variation being that we have to remove a proton throughout the reaction mechanism.
Figure: General mechanism for the nucleophilic substitution of a neutral nucleophile with a carboxylic acid derivative.
Similar mechanism holds true for nucleophilic substitutions of another carboxylic acid derivatives along with neutral nucleophiles and we can mark as a general mechanism. In practice, acids or bases are frequently added to enhance yields.