Implemented functional auto-save on window close

Signed-off-by: Jamie Redding <jamieredding2694@gmail.com>