I’m currently trying to do the same without success. As suggested in Ending the experiment when participants do not agree to participate - #10 by wakecarter, I have tried separately these two by inserting JS code at the end of a routine without any luck:
psychoJS.quit({message: 'Your custom message'});
quitPsychoJS('Your custom message', false);
However both end the experiment, the final message is always:
Thank you for your patience.
The [Escape] key was pressed. Goodbye!