Hi @David_Kamaru ! As you are new to the community, when you get a chance, please introduce yourself here.
I just want to make sure you are asking about ODK-X, and not ODK (ODK help here: https://forum.getodk.org/)
For ODK-X, you can do this with a question asking exactly as you say, ask are you willing to continue the questionnaire, and then if they select no, use a finalize prompt. See ODK-X XLSX Converter Reference — ODK-X Docs for information on how to construct conditions for the if.