Dismiss stateChangeStart after firing

I am doing an Automatic Login for my app where I save the credentials to localstorage and after running again statechangestart check if localstorage has data and go to the main page. My problem is How can I dismiss the function of statechangestart after it fires because the function runs again if I go to another state and ovewrites the state. Thanks… here is my code for the checking of localstorage:

$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {

		if (window.localStorage.getItem("username") === null && window.localStorage.getItem("password") === null) {
        else {