How can i close a room via code?

I’m doing some tests to close the JitsiMeet call via code, I tried a few things but it gave an error.

tried

jitsiMeetActivity.finish();

I also tried

jitsiMeetActivity.leave();

In both cases the error

java.lang.NullPointerException: Attempt to invoke virtual method 'void org.jitsi.meet.sdk.JitsiMeetActivity.finish()' on a null object reference