How to close a page and open another right after?

How do I close a page and open another one right away? When I try to do that, the page just comes back and doesn’t open the other one.

document.querySelector("#btn").addEventListener(‘click’, () => {
app.views.main.router.back();
app.views.main.router.navigate(’/base-page-3/’, { transition: ‘f7-cover’ })
})

It only works if I add a 1s timeout.