How to set a max amount for stamina to grow (2d game)

So I am working on a 2d pixelated game and I have managed to put a stamina bar in the system but whenever I release the button that I set the stamina to be consumed it just keeps on growing.