diff --git a/src/data_transfer.cpp b/src/data_transfer.cpp
index 8b75209978b7fa6e92b88fa2d90988241e548040..d7565c711574df3304e91e404ee90382987ee3b4 100644
--- a/src/data_transfer.cpp
+++ b/src/data_transfer.cpp
@@ -203,6 +203,8 @@ IncomingFile::process()
         auto shared = w.lock();
         if (!shared)
             return;
+        if (shared->stream_ && shared->stream_.is_open())
+            shared->stream_.close();
         auto correct = shared->sha3Sum_.empty();
         if (!correct) {
             // Verify shaSum