Fixes for JRE crashing on app exit