Proverbs 3:1-2:

My son, forget not my law; but let thine heart keep my commandments: For length of days, and long life, and peace, shall they add to thee.

See also:

Some of God’s Promises Have Conditions
Is There an Appointed Time for Each Person to Die?