intervalo claro e.close não é uma função

It's because of your IDE! Make sure your IDE didn't include automatic imports such as
import { clearInterval } from 'timers'; 
If so, remove them. Rest should be fine.
Defeated Dingo