code cleanup and fix bug that sometimes prevented tab notifications from working
fix bug
fix potential memory leak and move cleanup to the end of the function
mark exit_toxic_* functions as noreturn
fix another potential memory leak