kotlin destroy fragment and replace code example
Example: destory fragment
getSupportFragmentManager().beginTransaction().remove(yourFragment).commitAllowingStateLoss();
getSupportFragmentManager().beginTransaction().remove(yourFragment).commitAllowingStateLoss();