Inspired by #386, delete main windows on close