I found the problem.
As you can see i have a regular query at plugin_end for saving ppl at mapchange and another threaded query at client_disconnect.
The problem was that at plugin_end also client_disconnect is run so the query at plugin_end is unnecessary but even when i toke away the query at plugin_end the server still hangs at mapchange.
That was because if you run a threaded query on client_disconnect that is also run at plugin_end and that makes the server hang, probably because
the threaded query takes some time to finish and at plugin_end there is not time for that.
Im no expert at this but when i toke away the query at plugin_end and made the client_disconnect a regular query it works fine and saves the players excactly as i want it to.