alywas wait for working thread to finish, before free memory