From the official website of the European Union:
Travel documents for non-EU nationals
Passport and visa requirements
If you are a non-EU national wishing to visit or travel within the EU, you will need a passport:
- valid for at least 3 months after the date you intend to leave the EU country you are visiting,
- which was issued within the previous 10 years,
I doubt that they will stop you from exiting the Schengen Zone if your passport is valid for less than three months, although there may be other sanctions. The UK should let you in regardless of passport validity as long as you are a UK citizen.