moved post_experiment outside nested into its own script

post_experiment can now be called from a custom function (e.g., if you
want to end the experiment)