This is called optional stopping and it is not possible using a classic t-test, since Type I and II errors are only valid at a determined sample size. However, other tests make it possible: see safe anytime-valid statistics [1, 2] or, simply, bayesian testing [3, 4].
[1] https://arxiv.org/abs/2210.01948
[2] https://arxiv.org/abs/2011.03567
[3] https://pubmed.ncbi.nlm.nih.gov/24659049/
[4] http://doingbayesiandataanalysis.blogspot.com/2013/11/option...