diff --git a/magick/module.c b/magick/module.c
index 35157b3..68c238c 100644
--- a/magick/module.c
+++ b/magick/module.c
@@ -180,9 +180,13 @@
if (module_list != (SplayTreeInfo *) NULL)
module_list=DestroySplayTree(module_list);
if (instantiate_module != MagickFalse)
- (void) lt_dlexit();
+ {
+#if !defined(MAGICKCORE_JP2_DELEGATE)
+ (void) lt_dlexit(); /* Jasper has an errant atexit() handler */
#endif
- instantiate_module=MagickFalse;
+ instantiate_module=MagickFalse;
+ }
+#endif
(void) UnlockSemaphoreInfo(module_semaphore);
}