reworked window's open and close functions.