Dispose container on app shut down

Fixes #565.