diff --git a/server.js b/server.js
index fe0cb237addeb15951ed196ec40afcd8242e91e5..96c493f29d9ba9eaae6c1751d1704519c8e0af5f 100644
--- a/server.js
+++ b/server.js
@@ -150,6 +150,18 @@
     if (err) throw err
     // Create/activate the webtorrent module
     webtorrent.create(function () {
+      function cleanForExit () {
+        utils.cleanForExit(webtorrent.app)
+      }
+
+      function exitGracefullyOnSignal () {
+        process.exit()
+      }
+
+      process.on('exit', cleanForExit)
+      process.on('SIGINT', exitGracefullyOnSignal)
+      process.on('SIGTERM', exitGracefullyOnSignal)
+
       // ----------- Make the server listening -----------
       server.listen(port, function () {
         videos.seedAll(function () {
diff --git a/src/utils.js b/src/utils.js
index 7a5c7b7ea9c8ec8886ab77b03e5d5f4171ee30af..8ce1789f9b8030146501107abbcf517cdecf7be7 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -186,5 +186,10 @@
     return dec
   }
 
+  utils.cleanForExit = function (webtorrent_process) {
+    logger.info('Gracefully exiting')
+    process.kill(-webtorrent_process.pid)
+  }
+
   module.exports = utils
 })()
diff --git a/src/webTorrentNode.js b/src/webTorrentNode.js
index ebe8d5d81026217a36cdcc7fab47955369093115..507cf31fc025d2763013a1f9411f29b348517144 100644
--- a/src/webTorrentNode.js
+++ b/src/webTorrentNode.js
@@ -43,11 +43,23 @@
     ipc.serve(function () {
       if (!webtorrentnode.silent) logger.info('IPC server ready.')
 
+      // Run a timeout of 30s after which we exit the process
+      var timeout_webtorrent_process = setTimeout(function () {
+        logger.error('Timeout : cannot run the webtorrent process. Please ensure you have electron-prebuilt npm package installed with xvfb-run.')
+        process.exit()
+      }, 30000)
+
       ipc.server.on(processKey + '.ready', function () {
         if (!webtorrentnode.silent) logger.info('Webtorrent process ready.')
+        clearTimeout(timeout_webtorrent_process)
         callback()
       })
 
+      ipc.server.on(processKey + '.exception', function (data) {
+        logger.error('Received exception error from webtorrent process.', { exception: data.exception })
+        process.exit()
+      })
+
       var webtorrent_process = spawn(__dirname + '/webtorrent.js', host, port, { detached: true })
       webtorrent_process.stderr.on('data', function (data) {
         // logger.debug('Webtorrent process stderr: ', data.toString())
@@ -57,15 +69,6 @@
         // logger.debug('Webtorrent process:', data.toString())
       })
 
-      function exitChildProcess () {
-        if (!webtorrentnode.silent) logger.info('Gracefully exit child')
-        process.kill(-webtorrent_process.pid)
-        process.exit(0)
-      }
-
-      process.on('SIGINT', exitChildProcess)
-      process.on('SIGTERM', exitChildProcess)
-
       webtorrentnode.app = webtorrent_process
     })
 
diff --git a/src/webtorrent.js b/src/webtorrent.js
index 840f97671aed2cc42d4fb90e199ce97dc8327b97..18ae6b6baa098e7dda866060d3cb560a327e1efe 100644
--- a/src/webtorrent.js
+++ b/src/webtorrent.js
@@ -83,5 +83,9 @@
       ipc.of[nodeKey].emit(processKey + '.ready')
       console.log('Ready.')
     })
+
+    process.on('uncaughtException', function (e) {
+      ipc.of[nodeKey].emit(processKey + '.exception', { exception: e })
+    })
   }
 })()