Fix bug on close/minimize/expand window