Added event tracking and close handling.

Mouse and Keyboard states are now stored in the window.