fix ftruncate on close bug