working on threads for file transfer
fixed a small problem with the file transfer
all threads using files now close when application close.
Merge pull request #1 from kanekin/thread_fix

Thread fix