To become extinct something really bad has to happen. Gas giant Jupiter protects the Earth from killer asteroids, unfortunately sometimes one gets through and could hit the Earth. If it’s larger than 10 kilometers in size it will most likely wipe out humanity but probably not entirely.
A large coronal mass ejection from the Sun could easily wipe out most of our electronic devices, our entire society would collapse. The Earth’s magnetic field would get messed up which has severe consequences that will turn Earth into Mars v2.