Legality is not the issue. The agreement merely needs to reflect exactly what date the buyer and seller wish to prorate to. It is typically the actual date that sellers responsibility ends, and the buyers responsibility begins.
The proration, in order to be fair, is usually done as of the date that the change of possession takes place. Extending the contract closing date would typically push the proration date to the new closing date, on the assumption that the seller is continuing to have possession until the new closing date.
But if the new buyer takes possession before the new closing date, then it would make sense to prorate as of the date that the buyer takes possession.
As the seller you want to be sure that the buyer is using contract extensions responsibly and for good reasons. It is a sign of financing problems if the buyer extends a contract multiple times, or asks for a long period of days prior to the closing.
One final note: It is not a good idea to allow a buyer to take possession prior to closing, for a variety of reasons. (FYI)