minor fixes for when application closes and necessary buffer clears.