Sharona Fleming was written out of the TV series Monk primarily because Bitty Schram, the actress portraying her, quit the show over contract disputes.
In-Universe Explanation
Within the narrative of Monk, Sharona's departure occurred in 2004, following the events of the episode "Mr. Monk Takes His Medicine." Her character's in-show reason for leaving was to remarry her ex-husband, Trevor Howe. This provided a definitive resolution for her character arc, allowing her to move on to a new chapter in her life.
Real-World Reasons
The decision for Sharona to leave the series was rooted in real-world production challenges. Bitty Schram's departure was the direct result of contract disputes, leading to her eventual exit from the show. This ultimately led to the introduction of a new assistant for Adrian Monk, Natalie Teeger, portrayed by Traylor Howard.
It's also worth noting that prior to her final exit, Sharona's tendency to "quit" her job as Monk's assistant had become a humorous running gag within the series, adding a layer of meta-commentary to her eventual, permanent departure.
For more details on the characters, you can refer to the List of Monk characters on Wikipedia.