decouple module and module close logic
Signed-off-by: yejun81 <yejun81@gmail.com>