Use timeout for joining threads