Hopefully fix lock when exiting