fix to close when process exits