What can I deduct as expenses for rental being sold?

I owned a house in Cape May which was rented for the first part of the year (until April 2019). It was our family home until we moved to the UK in 2016; we rented it to some friends after that. Our tenants moved to another state in May 2019, and we were not planning to return to the States anytime soon, so we sold the house in September 2019. My question is, can I deduct ALL maintenance, etc. expenses for the property for the year 2019, or only those for the four months we had tenants? We needed to get some quite significant works done before we could sell (new septic system -- ouch!) and had yard maintenance, etc. to pay for even after the tenants moved out. Also, can I include the electric bills that we paid between our tenants moving out and the sale? Yes, I know I should have filed these taxes by the 15th of October. I've overpaid our taxes due, so hopefully the fine won't be too high.