def finalize_checkplot(cpx, outdir, all_lclistpkl, objfits=None):
    """This is used to prevent any further changes to the checkplot.

    cpx is the checkplot dict or pickle to process.

    outdir is the directory to where the final pickle will be written. If this
    is set to the same dir as cpx and cpx is a pickle, the function will return
    a failure. This is meant to keep the in-process checkplots separate from the
    finalized versions.

    all_lclistpkl is a pickle created by lcproc.make_lclist above with no
    restrictions on the number of observations (so ALL light curves in the
    collection).

    objfits if not None should be a file path to a FITS file containing a WCS
    header and this object. This will be used to make a stamp cutout of the
    object using the actual image it was detected on. This will be a useful
    comparison to the usual DSS POSS-RED2 image used by the checkplots.

    Use this function after all variable classification, period-finding, and
    object xmatches are done. This function will add a 'final' key to the
    checkplot, which will contain:

    - a phased LC plot with the period and epoch set after review using the
      times, mags, errs after any appropriate filtering and sigclip was done in
      the checkplotserver UI

    - The unphased LC using the times, mags, errs after any appropriate
      filtering and sigclip was done in the checkplotserver UI

    - the same plots for any LC collection neighbors

    - the survey cutout for the object if objfits is provided and checks out

    - a redone neighbor search using GAIA and all light curves in the collection
      even if they don't have at least 1000 observations.

    These items will be shown in a special 'Final' tab in the checkplotserver
    webapp (this should be run in readonly mode as well). The final tab will
    also contain downloadable links for the checkplot pickle in pkl and PNG
    format, as well as the final times, mags, errs as a gzipped CSV with a
    header containing all of this info (will be readable by the usual
    astrobase.hatsurveys.hatlc module).

    """
