We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Killing tasks on Startup fails on Windows (PC)
## Problem Definition

After an update Rotki would not restart on its own.

Closing the interface and restarting got no response at all (twice)

Logs showed an attempt to kill the tasks but recorded the failure.

## Logs

> 2024-04-19T13:56:55.600Z: (info): Checking for update
> 2024-04-19T13:56:57.360Z: (info): Update for version 1.32.2 is not available (latest version: 1.32.2, downgrade is disallowed).
> 2024-04-19T13:57:03.347Z: Restarting rotki-core> > 
> 2024-04-19T13:57:03.350Z: Starting windows process termination
> 2024-04-19T13:57:07.274Z: Currently running: 246 tasks
> 2024-04-19T13:57:07.280Z: Detected the following running rotki-core processes: 2880, 7092
> 2024-04-19T13:57:07.282Z: Preparing to call "taskill /f /t /PID 2880 /PID 7092" on the rotki-core processes
> 2024-04-19T13:57:07.752Z: Call to taskkill exited
> 2024-04-19T13:57:07.754Z: The 2 processes are still running. Waiting for 2 seconds
> 2024-04-19T15:18:54.047Z: 

Investigation and Remediation

Look for any running instances 

> C:\Windows\system32>tasklist | find "rotki"
> rotki.exe                    16380 Console                    1     17,608 K
> rotki.exe                    13204 Console                    1     10,436 K
> rotki.exe                    14164 Console                    1      8,596 K

Kill the running instances:

> C:\Windows\system32>taskkill /f /t /PID 16380 /PID 13204 /PID 14164
> SUCCESS: The process with PID 13204 (child process of PID 16380) has been terminated.
> SUCCESS: The process with PID 14164 (child process of PID 16380) has been terminated.
> SUCCESS: The process with PID 16380 (child process of PID 7124) has been terminated.

Could it be the reason It can't kill the running instances is because there is a typo in the code?

As per the log;

2024-04-19T13:57:07.282Z: Preparing to call "taskill /f /t /PID 2880 /PID 7092" on the rotki-core processes
----------------------------------------------------^^^^------------

The command is taskkill (two k's) NOT taskill (one k). 


-->


### System Description


Operating system: 

`systeminfo | findstr /C:"OS"`

OS Name:                   Microsoft Windows 10 Home
OS Version:                10.0.19045 N/A Build 19045
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Workstation
OS Build Type:             Multiprocessor Free
BIOS Version:              LENOVO DUCN33WW, 2021-08-10


Rotki version: 1.32.2


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `rotkehlchen/server.py`
Content:
```
1 import logging
2 import os
3 import signal
4 
5 import gevent
6 
7 from rotkehlchen.api.server import APIServer, RestAPI
8 from rotkehlchen.args import app_args
9 from rotkehlchen.logging import TRACE, RotkehlchenLogsAdapter, add_logging_level, configure_logging
10 from rotkehlchen.rotkehlchen import Rotkehlchen
11 
12 logger = logging.getLogger(__name__)
13 log = RotkehlchenLogsAdapter(logger)
14 
15 
16 class RotkehlchenServer:
17     def __init__(self) -> None:
18         """Initializes the backend server
19         May raise:
20         - SystemPermissionError due to the given args containing a datadir
21         that does not have the correct permissions
22         """
23         arg_parser = app_args(
24             prog='rotki',
25             description=(
26                 'rotki, the portfolio tracker and accounting tool that respects your privacy'
27             ),
28         )
29         self.args = arg_parser.parse_args()
30         add_logging_level('TRACE', TRACE)
31         configure_logging(self.args)
32         self.rotkehlchen = Rotkehlchen(self.args)
33         self.stop_event = gevent.event.Event()
34         if ',' in self.args.api_cors:
35             domain_list = [str(domain) for domain in self.args.api_cors.split(',')]
36         else:
37             domain_list = [str(self.args.api_cors)]
38         self.api_server = APIServer(
39             rest_api=RestAPI(rotkehlchen=self.rotkehlchen),
40             ws_notifier=self.rotkehlchen.rotki_notifier,
41             cors_domain_list=domain_list,
42         )
43 
44     def shutdown(self) -> None:
45         log.debug('Shutdown initiated')
46         self.api_server.stop()
47         self.stop_event.set()
48 
49     def main(self) -> None:
50         # disable printing hub exceptions in stderr. With using the hub to do various
51         # tasks that should raise exceptions and have them handled outside the hub
52         # printing them in stdout is now too much spam (and would worry users too)
53         hub = gevent.hub.get_hub()
54         hub.exception_stream = None
55         # we don't use threadpool much so go to 2 instead of default 10
56         hub.threadpool_size = 2
57         hub.threadpool.maxsize = 2
58         if os.name != 'nt':
59             gevent.hub.signal(signal.SIGQUIT, self.shutdown)  # type: ignore[attr-defined,unused-ignore]  # pylint: disable=no-member  # linters don't understand the os.name check
60         gevent.hub.signal(signal.SIGINT, self.shutdown)
61         gevent.hub.signal(signal.SIGTERM, self.shutdown)
62         # The api server's RestAPI starts rotki main loop
63         self.api_server.start(
64             host=self.args.api_host,
65             rest_port=self.args.rest_api_port,
66         )
67         self.stop_event.wait()
68
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/rotkehlchen/server.py b/rotkehlchen/server.py
--- a/rotkehlchen/server.py
+++ b/rotkehlchen/server.py
@@ -56,9 +56,17 @@
         hub.threadpool_size = 2
         hub.threadpool.maxsize = 2
         if os.name != 'nt':
-            gevent.hub.signal(signal.SIGQUIT, self.shutdown)  # type: ignore[attr-defined,unused-ignore]  # pylint: disable=no-member  # linters don't understand the os.name check
+            gevent.hub.signal(signal.SIGQUIT, self.shutdown)
+            gevent.hub.signal(signal.SIGTERM, self.shutdown)
+        else:
+            # Handle the window control signal as stated here https://pyinstaller.org/en/stable/feature-notes.html#signal-handling-in-console-windows-applications-and-onefile-application-cleanup  # noqa: E501
+            # This logic handles the signal sent from the bootloader equivalent to sigterm in
+            # addition to the signals sent by windows's taskkill.
+            # Research documented in https://github.com/yabirgb/rotki-python-research
+            import win32api  # pylint: disable=import-outside-toplevel  # isort:skip
+            win32api.SetConsoleCtrlHandler(self.shutdown, True)
+
         gevent.hub.signal(signal.SIGINT, self.shutdown)
-        gevent.hub.signal(signal.SIGTERM, self.shutdown)
         # The api server's RestAPI starts rotki main loop
         self.api_server.start(
             host=self.args.api_host,

{"golden_diff": "diff --git a/rotkehlchen/server.py b/rotkehlchen/server.py\n--- a/rotkehlchen/server.py\n+++ b/rotkehlchen/server.py\n@@ -56,9 +56,17 @@\n         hub.threadpool_size = 2\n         hub.threadpool.maxsize = 2\n         if os.name != 'nt':\n-            gevent.hub.signal(signal.SIGQUIT, self.shutdown)  # type: ignore[attr-defined,unused-ignore]  # pylint: disable=no-member  # linters don't understand the os.name check\n+            gevent.hub.signal(signal.SIGQUIT, self.shutdown)\n+            gevent.hub.signal(signal.SIGTERM, self.shutdown)\n+        else:\n+            # Handle the window control signal as stated here https://pyinstaller.org/en/stable/feature-notes.html#signal-handling-in-console-windows-applications-and-onefile-application-cleanup  # noqa: E501\n+            # This logic handles the signal sent from the bootloader equivalent to sigterm in\n+            # addition to the signals sent by windows's taskkill.\n+            # Research documented in https://github.com/yabirgb/rotki-python-research\n+            import win32api  # pylint: disable=import-outside-toplevel  # isort:skip\n+            win32api.SetConsoleCtrlHandler(self.shutdown, True)\n+\n         gevent.hub.signal(signal.SIGINT, self.shutdown)\n-        gevent.hub.signal(signal.SIGTERM, self.shutdown)\n         # The api server's RestAPI starts rotki main loop\n         self.api_server.start(\n             host=self.args.api_host,\n", "issue": "Killing tasks on Startup fails on Windows (PC)\n## Problem Definition\r\n\r\nAfter an update Rotki would not restart on its own.\r\n\r\nClosing the interface and restarting got no response at all (twice)\r\n\r\nLogs showed an attempt to kill the tasks but recorded the failure.\r\n\r\n## Logs\r\n\r\n> 2024-04-19T13:56:55.600Z: (info): Checking for update\r\n> 2024-04-19T13:56:57.360Z: (info): Update for version 1.32.2 is not available (latest version: 1.32.2, downgrade is disallowed).\r\n> 2024-04-19T13:57:03.347Z: Restarting rotki-core> > \r\n> 2024-04-19T13:57:03.350Z: Starting windows process termination\r\n> 2024-04-19T13:57:07.274Z: Currently running: 246 tasks\r\n> 2024-04-19T13:57:07.280Z: Detected the following running rotki-core processes: 2880, 7092\r\n> 2024-04-19T13:57:07.282Z: Preparing to call \"taskill /f /t /PID 2880 /PID 7092\" on the rotki-core processes\r\n> 2024-04-19T13:57:07.752Z: Call to taskkill exited\r\n> 2024-04-19T13:57:07.754Z: The 2 processes are still running. Waiting for 2 seconds\r\n> 2024-04-19T15:18:54.047Z: \r\n\r\nInvestigation and Remediation\r\n\r\nLook for any running instances \r\n\r\n> C:\\Windows\\system32>tasklist | find \"rotki\"\r\n> rotki.exe                    16380 Console                    1     17,608 K\r\n> rotki.exe                    13204 Console                    1     10,436 K\r\n> rotki.exe                    14164 Console                    1      8,596 K\r\n\r\nKill the running instances:\r\n\r\n> C:\\Windows\\system32>taskkill /f /t /PID 16380 /PID 13204 /PID 14164\r\n> SUCCESS: The process with PID 13204 (child process of PID 16380) has been terminated.\r\n> SUCCESS: The process with PID 14164 (child process of PID 16380) has been terminated.\r\n> SUCCESS: The process with PID 16380 (child process of PID 7124) has been terminated.\r\n\r\nCould it be the reason It can't kill the running instances is because there is a typo in the code?\r\n\r\nAs per the log;\r\n\r\n2024-04-19T13:57:07.282Z: Preparing to call \"taskill /f /t /PID 2880 /PID 7092\" on the rotki-core processes\r\n----------------------------------------------------^^^^------------\r\n\r\nThe command is taskkill (two k's) NOT taskill (one k). \r\n\r\n\r\n-->\r\n\r\n\r\n### System Description\r\n\r\n\r\nOperating system: \r\n\r\n`systeminfo | findstr /C:\"OS\"`\r\n\r\nOS Name:                   Microsoft Windows 10 Home\r\nOS Version:                10.0.19045 N/A Build 19045\r\nOS Manufacturer:           Microsoft Corporation\r\nOS Configuration:          Standalone Workstation\r\nOS Build Type:             Multiprocessor Free\r\nBIOS Version:              LENOVO DUCN33WW, 2021-08-10\r\n\r\n\r\nRotki version: 1.32.2\r\n\n", "before_files": [{"content": "import logging\nimport os\nimport signal\n\nimport gevent\n\nfrom rotkehlchen.api.server import APIServer, RestAPI\nfrom rotkehlchen.args import app_args\nfrom rotkehlchen.logging import TRACE, RotkehlchenLogsAdapter, add_logging_level, configure_logging\nfrom rotkehlchen.rotkehlchen import Rotkehlchen\n\nlogger = logging.getLogger(__name__)\nlog = RotkehlchenLogsAdapter(logger)\n\n\nclass RotkehlchenServer:\n    def __init__(self) -> None:\n        \"\"\"Initializes the backend server\n        May raise:\n        - SystemPermissionError due to the given args containing a datadir\n        that does not have the correct permissions\n        \"\"\"\n        arg_parser = app_args(\n            prog='rotki',\n            description=(\n                'rotki, the portfolio tracker and accounting tool that respects your privacy'\n            ),\n        )\n        self.args = arg_parser.parse_args()\n        add_logging_level('TRACE', TRACE)\n        configure_logging(self.args)\n        self.rotkehlchen = Rotkehlchen(self.args)\n        self.stop_event = gevent.event.Event()\n        if ',' in self.args.api_cors:\n            domain_list = [str(domain) for domain in self.args.api_cors.split(',')]\n        else:\n            domain_list = [str(self.args.api_cors)]\n        self.api_server = APIServer(\n            rest_api=RestAPI(rotkehlchen=self.rotkehlchen),\n            ws_notifier=self.rotkehlchen.rotki_notifier,\n            cors_domain_list=domain_list,\n        )\n\n    def shutdown(self) -> None:\n        log.debug('Shutdown initiated')\n        self.api_server.stop()\n        self.stop_event.set()\n\n    def main(self) -> None:\n        # disable printing hub exceptions in stderr. With using the hub to do various\n        # tasks that should raise exceptions and have them handled outside the hub\n        # printing them in stdout is now too much spam (and would worry users too)\n        hub = gevent.hub.get_hub()\n        hub.exception_stream = None\n        # we don't use threadpool much so go to 2 instead of default 10\n        hub.threadpool_size = 2\n        hub.threadpool.maxsize = 2\n        if os.name != 'nt':\n            gevent.hub.signal(signal.SIGQUIT, self.shutdown)  # type: ignore[attr-defined,unused-ignore]  # pylint: disable=no-member  # linters don't understand the os.name check\n        gevent.hub.signal(signal.SIGINT, self.shutdown)\n        gevent.hub.signal(signal.SIGTERM, self.shutdown)\n        # The api server's RestAPI starts rotki main loop\n        self.api_server.start(\n            host=self.args.api_host,\n            rest_port=self.args.rest_api_port,\n        )\n        self.stop_event.wait()\n", "path": "rotkehlchen/server.py"}], "after_files": [{"content": "import logging\nimport os\nimport signal\n\nimport gevent\n\nfrom rotkehlchen.api.server import APIServer, RestAPI\nfrom rotkehlchen.args import app_args\nfrom rotkehlchen.logging import TRACE, RotkehlchenLogsAdapter, add_logging_level, configure_logging\nfrom rotkehlchen.rotkehlchen import Rotkehlchen\n\nlogger = logging.getLogger(__name__)\nlog = RotkehlchenLogsAdapter(logger)\n\n\nclass RotkehlchenServer:\n    def __init__(self) -> None:\n        \"\"\"Initializes the backend server\n        May raise:\n        - SystemPermissionError due to the given args containing a datadir\n        that does not have the correct permissions\n        \"\"\"\n        arg_parser = app_args(\n            prog='rotki',\n            description=(\n                'rotki, the portfolio tracker and accounting tool that respects your privacy'\n            ),\n        )\n        self.args = arg_parser.parse_args()\n        add_logging_level('TRACE', TRACE)\n        configure_logging(self.args)\n        self.rotkehlchen = Rotkehlchen(self.args)\n        self.stop_event = gevent.event.Event()\n        if ',' in self.args.api_cors:\n            domain_list = [str(domain) for domain in self.args.api_cors.split(',')]\n        else:\n            domain_list = [str(self.args.api_cors)]\n        self.api_server = APIServer(\n            rest_api=RestAPI(rotkehlchen=self.rotkehlchen),\n            ws_notifier=self.rotkehlchen.rotki_notifier,\n            cors_domain_list=domain_list,\n        )\n\n    def shutdown(self) -> None:\n        log.debug('Shutdown initiated')\n        self.api_server.stop()\n        self.stop_event.set()\n\n    def main(self) -> None:\n        # disable printing hub exceptions in stderr. With using the hub to do various\n        # tasks that should raise exceptions and have them handled outside the hub\n        # printing them in stdout is now too much spam (and would worry users too)\n        hub = gevent.hub.get_hub()\n        hub.exception_stream = None\n        # we don't use threadpool much so go to 2 instead of default 10\n        hub.threadpool_size = 2\n        hub.threadpool.maxsize = 2\n        if os.name != 'nt':\n            gevent.hub.signal(signal.SIGQUIT, self.shutdown)\n            gevent.hub.signal(signal.SIGTERM, self.shutdown)\n        else:\n            # Handle the window control signal as stated here https://pyinstaller.org/en/stable/feature-notes.html#signal-handling-in-console-windows-applications-and-onefile-application-cleanup  # noqa: E501\n            # This logic handles the signal sent from the bootloader equivalent to sigterm in\n            # addition to the signals sent by windows's taskkill.\n            # Research documented in https://github.com/yabirgb/rotki-python-research\n            import win32api  # pylint: disable=import-outside-toplevel  # isort:skip\n            win32api.SetConsoleCtrlHandler(self.shutdown, True)\n\n        gevent.hub.signal(signal.SIGINT, self.shutdown)\n        # The api server's RestAPI starts rotki main loop\n        self.api_server.start(\n            host=self.args.api_host,\n            rest_port=self.args.rest_api_port,\n        )\n        self.stop_event.wait()\n", "path": "rotkehlchen/server.py"}]}