You can buy term life insurance that covers a specific amount of time, typically between 10 and 30 years.
Typically, premiums remain constant throughout the term, and the death benefit is guaranteed in the event of your death during the term.
https://youtu.be/pB-YtGUJ4KM