Improve alert handling to fix stuck-notification issue.