fixed bug closing before points are written