diff --git a/src/Main.cxx b/src/Main.cxx
index 06d7b1915..084d1ad4f 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -564,7 +564,7 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
 #ifndef ANDROID
 	setup_log_output();
 
-	SignalHandlersInit(instance->event_loop);
+	const ScopeSignalHandlersInit signal_handlers_init(instance->event_loop);
 #endif
 
 	instance->io_thread.Start();
@@ -676,9 +676,6 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
 #endif
 	instance->rtio_thread.Stop();
 	instance->io_thread.Stop();
-#ifndef ANDROID
-	SignalHandlersFinish();
-#endif
 
 	return EXIT_SUCCESS;
 }
diff --git a/src/unix/SignalHandlers.hxx b/src/unix/SignalHandlers.hxx
index d17c0504c..4808f97e5 100644
--- a/src/unix/SignalHandlers.hxx
+++ b/src/unix/SignalHandlers.hxx
@@ -28,4 +28,15 @@ SignalHandlersInit(EventLoop &loop);
 void
 SignalHandlersFinish() noexcept;
 
+class ScopeSignalHandlersInit {
+public:
+	ScopeSignalHandlersInit(EventLoop &loop) {
+		SignalHandlersInit(loop);
+	}
+
+	~ScopeSignalHandlersInit() noexcept {
+		SignalHandlersFinish();
+	}
+};
+
 #endif