I was told that the door of the toilet or the bathroom (if the toilet is in there) should always be kept shut; many times when not in use the door is left open and the Shayateen can enter the house from the open door. Is there evidence for this and is it a correct opinion?
There are no Islamic texts that specifically make it a requirement to close your bathroom door.
The only thing pointed out in Islamic texts is closing your house's doors at night, because the Jinn are outside during that time. They cannot open closed doors. From Bukhari (3304):
Allah's Messenger (ﷺ) said, "When night falls (or it is evening), keep your children close to you for the devils spread out at that time. But when an hour of the night elapses, you can let them free. Close the doors and mention the Name of Allah, for Satan does not open a closed door."
We do know that Jinn like to stay in dirty places like bathrooms/toilets, which is why the Prophet even gave a dua for protection when entering the bathroom/toilet (which you can read here). So some people may deduce that they ought to close the bathroom doors too to prevent Jinn from escaping into the rest of the house.. as an "extra protection".
But again, nothing specifically in Islam says/requires to do so.
In fact, to protect against Jinn being in the rest of your house, Islam actually gives a solution: reciting Qur'an. The Prophet said, "Satan runs away from the house in which Surah Baqara is recited" - Muslim (780).
Hope this helps.