Sounds like the two latches or pins are not locating fully.
Check that there is nothing stuck in the two holes in the part screwed to the tank. anything in the holes might stop the pins from returning fully.
Also check for any "step" or wear on the pins.
Sometimes on mime, I have to push down on the cap to locate the pins and get the key to return.