Add a safeguard to prevent unintentional progressbar overflow.