Ooh! My biggest tip for writing mysteries or thrillers (or even horror stories) is to know who (or what) is behind all the crazy ish that is happening and why they are doing the absolute most to terrorize the MC. I have read and watched a few thrillers that fell apart at the end because the villain and their reasoning for doing all that they did didn’t make any sense. I don’t mind plot twists, but plot twists shouldn’t be so shocking and “out of the blue” that it completely ruins the story.
Also, it helps to plot out what the villain is doing “behind the scenes” alongside what the MC is doing in the main scenes, so the story makes sense (in the case of thrillers). For example, the reader knows that the MC finds a mysterious note and then unexpectedly bumps into the villain (who we don’t know is the villain yet). But you, the writer, knows that after the villain left the note, they stalked the MC to make sure that they found it, then they played innocent and pretended to unexpectedly bump into the MC. You don’t have to explain everything the villain did at the end of the story, but knowing in the back of your mind really helps!