This should be easy enough to check if you always set database to null if it's not open then you can just check `if( !database ) return;`