Fixed bugs on close code and exit window