close profiling on script exits instead of page flushing