Some buffer/window trickery to get auto-closing working

Other alternatives tried either segfault or don't quite work correctly
in all cases. Mind you, no guarantee of this working, either.
Simple ad-hoc test script

Nothing serious yet, don't have the energy to build something at the
moment.