The Octave documentation on this subject is both intimidating and sparse.
I did not know where else to document the solution I found, so I am posting here. I apolog
Something I found when linking my custom m file into an Octave standalone:
#include
return 0;
clean_up_and_exit(0);
Without these steps my program repeatedly crashed on exit.