Bug fixing for window closing.