restore shell buffer on exit