I want to play Minecraft realms with friends but i want to know if they expire when closed so that I can have them closed while we're not gonna play
Do minecraft realms expire when closed?
I don't know
I don't fully understand what you're asking, but I'd say they don't
Since Minecraft Realms is a server subscription service, it runs on calendar days… So if choose to take a one-month subscription to Realms, you (& up to 10 of your friends at the same time) will be able to access that realm within that 30-day (1 month) period.
How the owner choose to manage the Realm (keeping it open all the time or shutting it down part of the time) is up to them. The online / offline status of the Realm does not affect the subscription time. Just be aware that when your Realm subscription expires, your realm will be permanently offline until you choose to renew it. For example, if you started a Realm subscription on June 15th for one month, it'll remain active until July 15th regardless how often or how long you choose to keep your Realm open or closed to your friends.
There are bulk subscriptions (for 3 & 6 months), which generally have discounts on them as well as an auto-renew option (requires a credit card) so you can keep your Realm for as long as you're willing to pay the subscription fees for it.
Minecraft Realms FAQ's does state that they will not delete your Realm after it expires… So whenever you want to return to an old Realm, you may do so by just renewing that subscription. HOWEVER, Minecraft Realms is NOT responsible for maintaining back-up copies of your Realm & may eventually delete your Realm as needed (to reclaim highly unused storage space), after some considerable time (we're talking multiple years here) when it may be considered "abandoned". Therefore, it is the owner's responsibility to make periodic back-ups of their Realm, just in case something goes wrong & the dirt blocks hit the proverbial fan.
Hope this helps!