Index: trunk/BNC/src/upload/bncrtnetdecoder.cpp
===================================================================
--- trunk/BNC/src/upload/bncrtnetdecoder.cpp	(revision 11153)
+++ trunk/BNC/src/upload/bncrtnetdecoder.cpp	(revision 11179)
@@ -88,4 +88,5 @@
 bncRtnetDecoder::~bncRtnetDecoder() {
   for (int ic = 0; ic < _casters.size(); ic++) {
+    _casters[ic]->closeFiles();
     _casters[ic]->deleteSafely();
   }
Index: trunk/BNC/src/upload/bncrtnetuploadcaster.cpp
===================================================================
--- trunk/BNC/src/upload/bncrtnetuploadcaster.cpp	(revision 11153)
+++ trunk/BNC/src/upload/bncrtnetuploadcaster.cpp	(revision 11179)
@@ -287,4 +287,15 @@
     delete _usedEph;
     delete _ssrCorr;
+}
+
+// Close the SP3, clock RINEX and Bias-SINEX files: done here, since the
+// destructor may run only after the end of the event loop (deleteLater),
+// i.e. not at all at the end of BNC
+////////////////////////////////////////////////////////////////////////////
+void bncRtnetUploadCaster::closeFiles() {
+  QMutexLocker locker(&_mutex);
+  delete _rnx; _rnx = 0;
+  delete _sp3; _sp3 = 0;
+  delete _bsx; _bsx = 0;
 }
 
Index: trunk/BNC/src/upload/bncrtnetuploadcaster.h
===================================================================
--- trunk/BNC/src/upload/bncrtnetuploadcaster.h	(revision 11153)
+++ trunk/BNC/src/upload/bncrtnetuploadcaster.h	(revision 11179)
@@ -33,4 +33,5 @@
         int PID, int SID, int IOD, int iRow);
     void decodeRtnetStream(char* buffer, int bufLen);
+    void closeFiles();
 protected:
     virtual ~bncRtnetUploadCaster();
