Close up PerfLog on every function return

This fixes a miscellaneous_ex11 bug with PerfLog enabled