A detective who created the viral "Duck of Justice" when he rescued a faux waterfowl headed for the trash bin is retiring to write a book.

Lt. Tim Cotton combined his sense of humor with the Bangor Police Department's social media account to show the human side of police work.

His "Duck of Justice" became a viral sensation as the fowl appeared in various locations before finding a permanent roost in police department, where author Stephen King and others have stopped by for photos.

WASHINGTON POST RELEASES UPDATED SOCIAL MEDIA POLICY FOLLOWING TWITTER MELTDOWN AMONG STAFF

Along the way, Cotton helped put the city of 30,000 on the social media map with 330,000 Facebook followers — including many outside Maine.

Portland, Cumberland, Augusta news

Maine Facebook creator of viral ‘Duck of Justice’ is retiring to create a book.

Cotton, 59, told the Bangor Daily News that it’s been frustrating in recent years to watch anti-police sentiment grow nationwide as officers grapple with how to handle tough issues like mental illness and substance abuse.

GREG GUTFELD: SOCIAL MEDIA USE CAN BE LIKE A BAD SMOKING HABIT

"Over the last 10 years, society has decided they don’t want police involved and yet they call police for each and every issue," he said. "We’ve taken on that responsibility because there was no one else to call."

In his retirement, Cotton will continue posting to the Duck of Justice’s Facebook page for the police department while pursuing his writing career. He already has published two books.

CONNECTICUT RIVER DOLPHIN SPOTTED SWIMMING IN SOCIAL MEDIA VIDEO

In the meantime, people should continue to heed the department's oft-repeated advice: "Keep your hands to yourself, leave other people’s things alone, and be kind to one another."