Yes, you can - as long as the layover is not labelled ‘Board only’ or similar. You can see in the online timetable or the app how long a train stops. You can also ask the train crew.
But be careful. Sometimes, the train stops for less time than indicated. This is particularly the case when the train is delayed. Stay close to the train door, don't linger too long, and pay attention to the train crew. Take your valuables with you, especially your smartphone, ticket, and ID.
Find your night train connection