How to stop tween from breaking when changing size

I want to reset the frame size whenever it reaches the maximum size without breaking the tween. When I change the size, the tween just stops.

local size = (randomNumber / 100) * 5
local targetSize = UDim2.new(size, 0, 1, 0)
local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
local tween = TweenService:Create(frame, tweenInfo, {Size = targetSize})
tween:Play()

tween.Completed:Connect(function()
	print("finished")
end)

frame:GetPropertyChangedSignal("Size"):Connect(function()
	local maxSize = UDim2.new(1, 0, 1, 0)

	if frame.Size.X.Scale >= maxSize.X.Scale then
		frame.Size = UDim2.new(0, 0, 1, 0)
		tween:Play()
	end
end)