cleanup
close cleanly when window is closed