Firefox Closes on its own without my help

I was trying to access Youtube but Firefox was not set up to view video. Needed Javascript or Flash which I tried to install. Apparently it did not install properly and every webpage with a link or Java or Flash automatically closes the browser. Even when I used the package manager to uninstall Firefox it still will not stay open once I reinstall it. Can anyone help?