Yes peanut butter should remained sealed when you're not eating it.
After using the peanut butter and after opening it make sure to put the lid back on the peanut butter jar so that it doesn't grow mold or any bacteria in it.
The opened jar of peanut butter as long as you keep the lid on it to seal it will last 3 months in the pantry although it will still be okay to eat after 3 months but the texture changes and it might dry out.
The peanut butter when not opened will last 3 to 5 years in the pantry before it goes bad.
Peanut butter doesn't need to be refrigerated and it actually remains fresher out of the refrigerator.
But just be sure to always close the lid on the peanut butter jar to keep it from going bad or drying out.