keep last state of window when quit fullscreen

keep last state of window when quit fullscreen and correct a bug when type alt + f4 when window is in fullscreen