Implemented proper minimizing and closing in OS X