If we never had an agreement for me to document all my work (extremely common) then the best they can do is say "hand over the keys" but they can't make you drive. If they're willing to invest in a new engineer's learning curve, the problems must be way deeper than 1 bill & you should've seen it coming, enough to write out a formal contract for that last bit. In hostile workplaces contracts should be the norm, sure, but I just try to avoid those situations to begin with.
Good advice on the email bit, but I kindof just assume that those count as written records. Either courts acknowledge them or they don't I'm not sure that explicitly saying they do really changes much.
Also, you say "there is a contract when you agree to exchange services for money" but if they don't pay you... didn't they already break that contract? Why would you have to do due diligence (maintenance) for someone who refuses to acknowledge your initial agreement?