Sunset

Sunset is an event that occurs at the end of each in-game day in the Pikmin games. When the sunset arrives, all leaders and Pikmin must stop what they are doing, retreat into the Onions and ship, and spend the night in low-orbit, due to the fact that many predators become active at night.

Safe Pikmin
When the sunset arrives, any Pikmin that are considered to be safe will be able to board their Onion, spend the night above the surface, and be ready to be picked up the following day. When the day ends, Pikmin will be considered safe if:
 * They are in a leader's group.
 * They are close to an activated Onion.
 * They are close to an inactivated Onion.

It does not matter which Onion the Pikmin is close to, even if the Pikmin's type does not match the Onion's type.

In addition to these, any Pikmin that is buried will stay where they are buried, and will not be harmed over the night. Any other Pikmin that isn't safe or buried will be left behind on the surface and will be eaten by enemies during the night.

added some ways to know for sure that Pikmin are safe. A large white circle appears around all activated Onions on the area, indicating that Pikmin within it will be safe. Although unactivated Onions do not show the circle, the safety radius still exists, and if a dormant Onion is activated after the sunset warning period begins, the circle will still not appear, but nearby Pikmin will still be counted as safe. A small counter will appear on the top-right corner of the screen to alert the player of how many Pikmin are in danger of being left behind. What types of Pikmin that are idle are displayed near the top of the map, along with how many. Pikmin icons will also appear larger on the radar when the sunset is approaching, and the icons of those that are at risk of being left on the surface will also appear flashing on the radar. Finally, when the player attempts to finish the day from the pause menu, a warning will show up saying that Pikmin will be left behind if there are indeed any Pikmin considered not safe when the player tried to end the day.

Warning
Some minutes before the sun is down, a message will appear on-screen warning the player that they need to gather their Pikmin. From here on, the music changes to a calmer remix. It is also at this point that the KopPad changes, and the Onions get their safety limits shown, in Pikmin 3. From Pikmin 2 onward, the normal area music fades out a couple of seconds before this phase begins.

Countdown
Some time after the warning, a countdown from 10 takes place. Each digit takes a few seconds to pass and is presented on-screen, slowly fading away to make way for the next one. 0 also appears, and the day doesn't end until after the 0 disappears completely.

Gathering
When the countdown finishes, or when the day is ended with the pause menu, two cutscenes take place. The first scene starts with all alive leaders and safe Pikmin following the leaders walking up to the landing site in a single group led by the leader who was selected when the day ended. The main leader then dismisses and orders every Pikmin to get on their Onions or ship. Any Pikmin that is near an Onion, but away from the landing site will still climb to their Onion, despite not being shown. Any Pikmin that are buried will remain buried in the same spot and can be plucked on another day. After all the Pikmin have entered their Onion, the leaders are beamed into the ship.

Lift off
The second cinematic shows the ship preparing for lift-off, while wild creatures draw near. If any Pikmin were not considered safe, they'll be shown running towards the ship in an attempt to be saved. However, it is too late, and the wandering enemies will begin to eat them. The ship then takes off into the night sky.

=In fanon games=

In Pikmin: Wide World
Sunset is an event that occurs at the end of each in-game day in Pikmin: Wide World, and it begins one-and-a-half real-time minutes before the end of the in-game day.