Make sure BEB JE commits survive application crashes and the datastore properly closes the repository

This fixes #544