Improve modified buffers check on exit