Ensure that cleanup is possible without at_exit.

Resolves #7.