Paul knew that he was just a stranger in this earth, he knew what awaits him at the other end of life.
Such courage only comes when you no longer have a will of your own but the will of God controlling you. Dying becomes a gain because of the crown of glory waiting for you