diff --git a/src/core/tandem_run/tandembatchprocess.cpp b/src/core/tandem_run/tandembatchprocess.cpp
index 5d02124c7503ee94866df892dbc29c2996813a73..6a07083ecf9315ec9406d220015e8edab74dff4d 100644
--- a/src/core/tandem_run/tandembatchprocess.cpp
+++ b/src/core/tandem_run/tandembatchprocess.cpp
@@ -41,6 +41,10 @@ TandemBatchProcess::TandemBatchProcess(WorkMonitorInterface * p_monitor, const T
 
 TandemBatchProcess::~TandemBatchProcess() {
 }
+
+bool TandemBatchProcess::shouldIstop() {
+    return false;
+}
 void TandemBatchProcess::writeXmlDatabaseFile (QXmlStreamWriter * p_out) {
     p_out->setAutoFormatting(true);
     p_out->writeStartDocument("1.0");
@@ -94,6 +98,9 @@ void TandemBatchProcess::run() {
     int i=0;
     _p_monitor->setProgressMaximumValue(_tandem_run_batch._mz_file_list.size());
     for (QString mz_file : _tandem_run_batch._mz_file_list) {
+        if (shouldIstop()) {
+            throw pappso::PappsoException(QObject::tr("X!Tandem stopped by the user processing %1 sample").arg(mz_file));
+        }
         _p_monitor->message(QObject::tr("running X!Tandem on %1\n").arg(mz_file), i);
         runOne(mz_file);
         i++;
@@ -209,6 +216,11 @@ void TandemBatchProcess::runOne(const QString & mz_file) {
     while(xt_process->waitForReadyRead(_max_xt_time_ms)) {
         _p_monitor->appendText( xt_process->readAll().data());
         //data.append(xt_process->readAll());
+        if (shouldIstop()) {
+            xt_process->kill();
+            delete xt_process;
+            throw pappso::PappsoException(QObject::tr("X!Tandem stopped by the user processing %1 sample").arg(mz_file));
+        }
     }
     /*
     if (!xt_process->waitForFinished(_max_xt_time_ms)) {
@@ -219,11 +231,11 @@ void TandemBatchProcess::runOne(const QString & mz_file) {
 
     QProcess::ExitStatus Status = xt_process->exitStatus();
 
+    delete xt_process;
     if (Status != 0)
     {
         // != QProcess::NormalExit
         throw pappso::PappsoException(QObject::tr("error executing X!Tandem Status != 0 : %1 %2\n%3").arg(_tandem_run_batch._tandem_bin_path).arg(arguments.join(" ").arg(result.data())));
     }
 
-    delete xt_process;
 }
diff --git a/src/core/tandem_run/tandembatchprocess.h b/src/core/tandem_run/tandembatchprocess.h
index 1ce5bb7881f2a853a04f0fecadee9c7ba77f8fc5..0aed96910583b9774c41bd32db266922fa2f2411 100644
--- a/src/core/tandem_run/tandembatchprocess.h
+++ b/src/core/tandem_run/tandembatchprocess.h
@@ -47,6 +47,7 @@ protected:
     virtual void prepareXmlDatabaseFile();
 private:
     void runOne(const QString & mz_file);
+    bool shouldIstop();
 
 protected:
     QString _preset_file;
diff --git a/src/gui/workerthread.cpp b/src/gui/workerthread.cpp
index 265325d5a4f2317861b79290d010da1b41091295..4919ad087c3b091ddb1f4c30cf3d0c0bc24d6bac 100644
--- a/src/gui/workerthread.cpp
+++ b/src/gui/workerthread.cpp
@@ -43,6 +43,7 @@
 
 WorkerThread::WorkerThread(MainWindow * p_main_window)
 {
+    _p_main_window = p_main_window;
     qDebug() << "WorkerThread::WorkerThread begin MainWindow";
 
     _p_work_monitor = new WorkMonitor();
diff --git a/src/gui/workerthread.h b/src/gui/workerthread.h
index 007d190b8e7f7cf21e2f5939421a6f544f3b6ce8..d357d710e88704c2118f61af6280d6045038b331 100644
--- a/src/gui/workerthread.h
+++ b/src/gui/workerthread.h
@@ -79,6 +79,7 @@ signals:
     
 private:
     WorkMonitor * _p_work_monitor;
+    MainWindow * _p_main_window;
 };
 
 #endif // WORKERTHREAD_H