- In the end, you'll have to decide for yourself.
- Properly handing over is decent, required by employment contract, and probably best for you (via professional reputation)
- As you are already recognized for your helpfulness, don't sabotage that reputation.
- Don't be surprised if your supervisor isn't interested in a proper handover, though.
Long version: Here's what'd do/did do.
To what extent should I cooperate? One the one hand, cooperation seems like the decent thing to do. I am dependent on my employer's recommendations, and do not want to burn bridges.
Cooperating is not only the decent thing to do, properly handing over your work is also one of your duties as employee.
On the other hand, I would abolish my employer's need for me, which feels like self-sabotage.
Overall, I don't think so - I think good cooperation is also in your direct own interest.
- Sure, there may be (are) employers/supervisors out there that decide on the basis of such need.
My experience with academic employers is that they'd rather abandon the tools, though.
The more so, the less they can judge the importance and quality of the tools (see also Why do many talented scientists write horrible software? - which does not imply anything about the quality of your tools, but this is roughly what I'd expect someone without in-depth knowledge of your code to estimate).
This means: even if they objectively need you they are unlikely to realize how much*.
Meaning your actual advantage on keeping that knowledge for yourself is probably close to zero.
Now consider the potential advantages of leaving with good cooperation:
This is part of building up your professional reputation. Of course, you may decide for a path of least resistance and not throw in more work than you can get away with. But if you want to build up a recommendation of integrity, being dependable and reliable and writing reliable software etc., this is a chance to get a step further in that direction.
Your next employer/supervisor may be interested in your attitude towards collaboration - after decently handing over your work, you have a "hard data point" that you can refer to.
Academia is a small world - your employer's recommendations (or warnings) possibly won't end with the letter of recommendation you get now. People talk at conferences, etc.
My experience of employers abandoning tools is that this can actually be
to the extent that they may not even want the work handed over. In that case, you'd win two ways: you did the decent and correct thing and offered handing over. And you don't even need to actually give up your advantage in knowledge.
One anecdata point: Personally, I can say that I have ongoing collaboration with a group I left almost 10 years ago, and other former employers/groups are now my customers (I'm freelancer now, though still associated with academic research projects).
And I have customers of whom I know that they'd not hire me if I had not that professional reputation of integrity.
those that can make hiring decisions have indicated that they would keep me because of experience and general helpfulness, if not [...] complications.
Don't sabotage your helpfulness!
* I'm speaking as a chemist who programs as part of my work. If you are computer scientist in a CS group, the chances that your good code is recognized as such may be much greater for you than for me. Similarly, my supervisors would have been more likely to recognize the need to keep someone looking after instrumentation that they understand better than they understand software quality.