Can I settle an open account with my deposit?

It happens that tenants settle their last month’s rent, outstanding service costs, etc. with the deposit. Legally speaking, this is not allowed, but there are landlords who do agree to this, especially after a final inspection which shows that the house is completely in order.