If foil is pulling away from the glass on the perimeter of pieces, there are several things to remember.
Clean all the edges and surfaces just before foiling. This ensures there are no oils to interfere with the contact adhesive of the foil.
Avoid hand creams just before foiling as this increases the amount of oils getting onto the glass.
Remember that lots of heat breaks down the adhesive. So do not remain in one place too long. However the adhesive is not the element that keeps the foil attached to the glass in the long term.
Instead, think about whether the bead on the edge is thick enough to provide the rigidity required without relying on the adhesive of the foil.
Finally, think about whether an edging came would provide better support and finish to the piece.