Fixed issue with exit causeing db instablility