Joss Whedon, the director of the box-office smash Avengers: Age of Ultron, has quit Twitter and deleted his account after facing criticism of his depiction of female characters in the movie.

Age of UltronJoss Whedon faced criticism over his portrayal of Scarlett Johansson's character in Age of Ultron

In a final message to fans, Whedon wrote: "Thank you to all the people who've been so kind and funny and inspiring up in here." 

It comes after some viewers of Age of Ultron went on Twitter to vent about perceived sexism in the representation of Scarlett Johansson's character Black Widow and Elizabeth Olsen's Scarlet Witch.

More: Avengers: Age of Ultron does massive, MASSIVE, business 

The comedian and actor Patton Oswalt defended Whedon and attacked his critics.

"Yep. There is a "Tea Party" equivalent of progressivism/liberalism. And they just chased Joss Whedon off Twitter. Good job, guys. Ugh."

Whedon has a chequered history with Twitter and told Entertainment Weekly: "It's a fascinating medium, it's a fascinating social phenomenon. People are like, 'It's like a drug.' Yeah, and it's like a job. It's just another art form. Until I have a script I truly believe in or a tweet that's really remarkable, I can just walk away and get back to the storytelling I need to do."

The director made headlines after criticizing the trailer for Jurassic World on Twitter, saying, "I'm too busy wishing this clip wasn't 70s era sexist. She's a stiff, he's a life-force - really? Still?" He later apologised, saying: "it's uncouth of me to attack somebody else's material."

To date, Avengers: Age of Ultron has taken $630 million globally. 

More: Avengers: Age of Ultron scripts destroyed daily to avoid leaks