That is what Paul says in Philippians as he writes from jail, expecting execution.

To under-stand what Paul meant, we must invest our whole life in Christ then our life is from, by, in, and for Christ: He is our inspiration and breath, the source, motive, and secret of our new being, the goal of all our interests and efforts. We are His slaves, living to do His will: Him we will trust, love, obey, preach, follow, and for Him we will suffer. Death is a gain because Paul has Christ here and hereafter. “To live is Christ and therefore to die is gain.”

To live is Christ, and to die is Christ too, plus a crown (2 Tim.4:7-8; Rev.2:10). Death is better, as it is better to be done with sin, conflict, obstacles, to have prayers answered and hopes realized, to be beyond danger, to be completely and intimately united with Him whom we love and to live in glory with Him (Rom. 8: 17; Co1.3: 4) . (William Beck)