Add a function to stop profiling after period