To stop tracking events under the same UserID after logging out of the application used reset method.
Analytics.shared().reset()
With this change, a new session is initiated by closing the previous session, and the userID appears as "-" in User Properties. However, the events are still being displayed under the same old user's event stream. instead of displaying under the anonymous user.