Working as intended end of thread