I have been thinking about this, and it's a tricky question. since God sees ALL time, and actions have consequences; is the amount of virtue\sin of an action, cut off when you die, or is it "retroactively computed" to your soul, based on the impact your actions had\will have, in the future? For example if someone creates a trust fund for charity, but dies soon after, does God allot him the total virtue of all the poor people who were helped after he died? or if you create a new drug, do you suffer the punishment of everyone who will ever die from using that drug?
There is a prayer: ‘Eternal Father, I offer you whatever I do, sacrifice and suffer, united with the merits of Jesus and Mary, with the will to work and continue to work for eternity’. Every action will be judged according to whether it was done out of love for God and the neighbour or for selfish reasons. What counts here is not so much the size or obviousness of the action, but what took place in the heart. We can have the will to do good works, any positive consequences of our actions are the result of grace, they are not our merit. But we have contributed to them through our will. It is the same in the negative case. If we commit a grave sin, that is, if we consciously decide to commit a serious offence against God's commandments, then this willing of evil is our fault. We are to blame for the chain of negative consequences that result from this, but we can no longer undo or stop them ourselves, even if we confess. For this we need God's help. We are responsible for our will.