I placed a piston down and powered it on top and it extended, then I tried unpowering it, but it did not retract. I rebuilt it a block away and it worked that time. Then I rebuilt it again and it didn't work again. It seems to depends on where the piston is placed and in what direction.
Once you build it, it either retracts or it doesn't. I built a lot and some do retract and others do not unless there's a block update. I checked to see if it had something to do with chunk borders but I don't think so
How to recreate: Place a piston facing sideways, blocks above it horizontally to run a redstone line and a lever at the end to power it. It extends when powered but it does not always retract.
(I tested it in 1.12 and 1.13 and both have the same issue)