Use of the WKB and variational methods to calculate the final stages of charge transfer in a CCD