trying to close a window

i think it might make more sense to totally rewrite this whole file from scratch