By St. John the Prophet
Question 736: If one enters the church during the time of liturgy and leaves before the end, is this a sin?
Response: What is perfect and pleasing to God is for the person entering the church to hear the Scriptures and remain in the liturgy until the very end. For unless there is good reason, one should not leave before the end; for this is scornful. If some need presents itself, then that person has permission to leave early. However, even then, such a person should not justify oneself, but ask forgiveness from God, saying: "Master, forgive me; for, I was not able to stay."
From The Letters of Saints Barsanuphios and John; translated by John Chryssavgis.