Working around connection problems with Emacs Tramp

From time to time I have to edit files on a SunOS 5.10 server. I use Emacs with tramp for this. However, after some time I get this error message from tramp:

File error: Couldn’t find exit status of `test -e …

It seems that the ssh connection goes bad for some reason. After this you won’t be able to save the file anymore. You can work around this by running M-x tramp-cleanup-all-connections and then saving again.