{
// shutdown the scheduler, otherwise Quartz scheduler and Threads still exists
Field schedulerField = taskScheduler.getClass().getDeclaredField( "scheduler" );
schedulerField.setAccessible( true );
DefaultScheduler scheduler = (DefaultScheduler) schedulerField.get( taskScheduler );
scheduler.stop();
}
catch ( Exception e )
{
log.error( "Error occurred while stopping scheduler.", e );
}