If one asks for forgiveness just before they take their life wouldn’t they be forgiven?
If you’re a born again believer all your sins were forgiven at the cross, even those you haven’t committed yet. And that includes the sin of taking your own life.
If you are not born again, then none of your sins are forgiven, and by taking your own life you will bring to an end the lifetime God has given you to accept the pardon Jesus purchased for you with His life.
You will die remaining personally responsible to God for the penalties for all your sins without any further opportunity to change your mind (Hebr. 9:27).
If you are considering taking your life and don’t understand what happened at the cross and how it benefits you, you owe it to yourself to find out for sure before taking any action.