I am living in Germany. My residence permit expires on 31st August 2021. Can I book my flight to India on 1st September 2021?

I am living in Germany. My residence permit expires on 31st August 2021. Can I book my flight to India on 1st September 2021? Will there be any penalty? Will, there be any penalty, or will I face any problem the next time I come