dispose view after switching states