If I show up for confession but the priest isn’t there, will my sins be forgiven if I am immediately killed?

Well the answer is, while the act of showing up for confession does not, in itself, obtain forgiveness of sins, it may be an indication of contrition—”sorrow of the soul and detestation for the sin committed, together with a resolution not to sin again” (CCC 1451). Contrition does forgive sins when it is perfect. The Catechism explains: “When it arises from a love by which God is loved above all else, contrition is called ‘perfect’ (contrition of charity). Such contrition remits venial sins; it also obtains forgiveness of mortal sins if it includes the firm resolution to have recourse to sacramental confession as soon as possible” (CCC 1452), Catechism of the Catholic Church.