add function to notify the message when the app is closed.