Added a function that demonstrates how we can use RAII to finish thread