Add shutdown event

Add event to shutdown, close all database connections on shutdown.